Ok… I get that the environments are not the same from Shell vs the Terminal App…
but is there a way to determine WHAT is not the same …
I have a rather long command line that when pasted into Terminal works perfectly
but when run from a shell… it runs about 1/2 way and then spits out a “Permission Denied for Mkdir” error
The app the is running via the Shell is Jazzy (a documentation generator)… which from what I can tell has components written in Ruby (which is mentioned in the error)
Unfortunatly it doesn’t tell me what directory it is trying to make (although I’m pretty sure its the very top level one, since that is what /docs is). I have tried pointing it to various locations , seting the write permissions on the destination ahead of time etc.
I have attempted
executing the whole command from Shell
writing to a BAT file first, and executing that
It “looks” like if I create /Docs and set it to 777 it then fails at Mkdir for some sub directory… but I can’t make the whole directory system ahead of time as it changes
Well I would assume if it did, it would from the command line as well as from Shell
My “front-end” app takes input from a User Dialog and creates a command string based on that… it could be a few dozen characters long to a few hundred depending on the chosen options… then it uses Shell to execute it…
It then processes X number of files (depending on the provided directory) and then writes its output to a Folder Structure (it creates an HTML website). It gets thru the processing part just fine (it logs each file as it goes)… But the instant it begins to create the file structure is when it fails
this is my test “command”
/usr/local/bin/jazzy --min-acl public --theme apple --source-directory="/Users/davidS/Desktop/jazzy_test/jazzy_test"
this is the log from running via Shell
Running xcodebuild
Parsing jazzy2.swift (1/4)
Parsing AppDelegate.swift (2/4)
Parsing ViewController.swift (3/4)
Parsing stuff.swift (4/4)
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:254:in `mkdir': Permission denied @ dir_s_mkdir - /docs (Errno::EACCES)
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:254:in `fu_mkdir'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:228:in `block (2 levels) in mkdir_p'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:226:in `reverse_each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:226:in `block in mkdir_p'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:211:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:211:in `mkdir_p'
from /Library/Ruby/Gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy/doc_builder.rb:26:in `prepare_output_dir'
from /Library/Ruby/Gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy/doc_builder.rb:152:in `build_docs_for_sourcekitten_output'
from /Library/Ruby/Gems/2.3.0/gems/jazzy-0.9.3/lib/jazzy/doc_builder.rb:77:in `build'
from /Library/Ruby/Gems/2.3.0/gems/jazzy-0.9.3/bin/jazzy:15:in `<top (required)>'
from /usr/local/bin/jazzy:22:in `load'
from /usr/local/bin/jazzy:22:in `<main>'
this is the log from Terminal
Daves-iMac:Desktop davidS$ /usr/local/bin/jazzy --min-acl public --theme apple --source-directory="/Users/davidS/Desktop/jazzy_test/jazzy_test"
Running xcodebuild
Parsing jazzy2.swift (1/4)
Parsing AppDelegate.swift (2/4)
Parsing ViewController.swift (3/4)
Parsing stuff.swift (4/4)
100% documentation coverage with 0 undocumented symbols
included 4 public or open symbols
skipped 4 private, fileprivate, or internal symbols (use `--min-acl` to specify a different minimum ACL)
building site
building search index
jam out ?? to your fresh new docs in `docs`
tried that already… .even pre-created the top level… it looks like the app needs permissions other that “default”, and I’m not sure how to give it .
The above command line has an "output’ option… by default it uses the same directory as “source”… I have pointed it at the desktop and a few other places… exact same error in all cases
[quote=40068:@Thomas Tempelmann]Your shell command executes in a directory that has no write permissions, obviously.
Try this:
s.Execute(“pwd”)
And then see what it outputs. I guess it’s either “/”, i.e. the root dir, which is usually protected.[/quote]
[quote=397718:@Dave S]BINGO!!!
I had my app creating a BAT file instead of just the one big command
The first line was CD
but I guess BASH is picky… CD didn’t change the path (PWD=/), but “cd” did
I stuck PWD and WHOAMI into the batch file… and now everything seems to work
now to get things pointing back where I want them to be[/quote]
It’s trying to make a docs folder at root and the application’s user can’t do that.
When I need to pass explicit path data to a shell command, I use variables built from the FolderItem.NativePath (versus FolderItem.ShellPath). It adds a few steps up front, but I then know when I pass the path info to the shell, I’m getting what I think I’m getting.
I also use NativePath and quote the parameter:
theDocsPath = SpecialFolder.Dcuments.NativePath
Then, I call the shell with:
theShell.Execute “mkdir “”” + theDocsPath + “/A New Folder”“”
(and yes, I know that’s more easily done just by calling f.CreateAsFolder:
[code]f = SpecialFolder.Documents.Child(“A New Folder”)
If f <> Nil And Not f.Exists Then
f.CreateAsFolder
If f.LastErrorCode <> 0 Then
End If
End If[/code])
That way, no surprises with unexpected escaped spaces or special characters in part of the path and non-escaped in other parts.
yeah I figured that out… the CD command I was using wasn’t doing its job… turns out BASH required “cd” for some reason (at least via Shell). And I had/have no control over the MKDIR command itself as it was being issued by a Ruby script buried deep inside a “GEM” (whatever that is)… but once I figured out the script was case sensitive, that solved the problem… strange