-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seems to be an issue if there is a space anywhere in the file path of the directory #38
Comments
It looks like it's caused by the fact that we set RUBYOPT in order to require a file. This filename contains a space, which borks the Ruby command line options parser. One solution is to put restore_environment.rb in the standard Ruby load path so that we don't have to reference the full filename. |
I've tried some different things, but can't seem to get anything working. What is the best way to do that @FooBarWidget? and Thanks so much for your help and this awesome project! 🍻 |
Move restore_environment.rb to lib/ruby/lib/2.1.0/. Then change the RUBYOPT option in lib/ruby/bin/ruby_environment to -rrestore_environment (without the full path). |
Thanks @FooBarWidget moving and then changing echo RUBYOPT=\"-r$ROOT/lib/restore_environment\"
echo GEM_HOME="$ROOT/lib/ruby/gems/2.1.0"
echo GEM_PATH="$ROOT/lib/ruby/gems/2.1.0" to echo RUBYOPT="-rrestore_environment"
echo GEM_HOME=\"$ROOT/lib/ruby/gems/2.1.0\"
echo GEM_PATH=\"$ROOT/lib/ruby/gems/2.1.0\" worked 👍 |
Are there any disadvantages to doing this? If not, why don't we make this a default? This is especially problematic when you bundle a Ruby for an OSX app, as those are very likely to contain spaces. Either that, or it might be worth adding something like my # ...
def create_package(target, os_type = :unix)
package_dir = "resources/bin/#{PACKAGE_NAME}-#{PACKAGE_VERSION}-#{target}"
sh "rm -rf #{package_dir}"
sh "mkdir -p #{package_dir}/lib/app"
sh "cp #{PACKAGE_MAIN} #{package_dir}/lib/app/"
sh "mkdir -p #{package_dir}/lib/ruby"
sh "mkdir -p packaging/"
sh "tar -xzf packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-#{target}.tar.gz -C #{package_dir}/lib/ruby"
if os_type == :unix
sh "cp packaging/wrapper.sh #{package_dir}/#{PACKAGE_NAME}"
else
sh "cp packaging/wrapper.bat #{package_dir}/#{PACKAGE_NAME}.bat"
end
sh "mkdir -p packaging/vendor/"
sh "cp -pR packaging/vendor #{package_dir}/lib/"
sh "cp Gemfile Gemfile.lock #{package_dir}/lib/vendor/"
sh "mkdir #{package_dir}/lib/vendor/.bundle"
sh "cp packaging/bundler-config #{package_dir}/lib/vendor/.bundle/config"
if os_type == :unix
# Hack to get paths containing spaces to behave correctly
# @see https://github.com/phusion/traveling-ruby/issues/38
sh %Q{sed -i '' -e 's|RUBYOPT=\\\\"-r$ROOT/lib/restore_environment\\\\"|RUBYOPT=\\\\"-rrestore_environment\\\\"|' #{package_dir}/lib/ruby/bin/ruby_environment}
sh %Q{sed -i '' -e 's|GEM_HOME="$ROOT/lib/ruby/gems/2.1.0"|GEM_HOME=\\\\"$ROOT/lib/ruby/gems/2.1.0\\\\"|' #{package_dir}/lib/ruby/bin/ruby_environment}
sh %Q{sed -i '' -e 's|GEM_PATH="$ROOT/lib/ruby/gems/2.1.0"|GEM_PATH=\\\\"$ROOT/lib/ruby/gems/2.1.0\\\\"|' #{package_dir}/lib/ruby/bin/ruby_environment}
sh "mv #{package_dir}/lib/ruby/lib/restore_environment.rb #{package_dir}/lib/ruby/lib/ruby/2.1.0/restore_environment.rb"
sh "tar -czf #{package_dir}.tar.gz #{package_dir}"
else
sh "zip -9r #{package_dir}.zip #{package_dir}"
end
end
# ... Is this also a potential issue with Windows? I haven't had a chance to test that. |
It's simply because I haven't had time yet. |
Installing to any directory with spaces in the path failed because of GEM_HOME and GEM_PATH having not enough quotes around them and ruby failing to parse the options from RUBYOPT when the -r option had spaces in it. Fixed this by adding the necessary escapes to add doublequotes around the env variables and moved restore_environment.rb to the lib/ruby/site_ruby/ folder, which is in the ruby load path, so the -r option doesn't need to reference the full absolute path. Fixes phusion#38.
…ath with spaces traveling-ruby failed to run when installed in a directory with spaces in the path. (See: phusion/traveling-ruby#38) Worked around this by adding the necessary escapes for quotes with `sed` in the build script. Also opened a PR with a proper upstream fix: phusion/traveling-ruby#94
…ath with spaces traveling-ruby failed to run when installed in a directory with spaces in the path. (See: phusion/traveling-ruby#38) Worked around this by adding the necessary escapes for quotes with `sed` in the build script. Also opened a PR with a proper upstream fix: phusion/traveling-ruby#94
so running
./hello-1.0.0-osx/hello
worksbut changing the directory with
mv hello-1.0.0-osx hello\ 1.0.0-osx
and running
./hello\ 1.0.0-osx/hello
causes
/Users/danmanstx/Desktop/ruby/traveling-ruby-hello-demo/hello 1.0.0-osx/lib/ruby/bin/ruby: line 14: 1.0.0-osx/lib/ruby/lib/ruby/gems/2.1.0: No such file or directory
I am really running into this when using a packaged ruby inside of something that resides in Application Support on Mac OS X. Above is just a simplified example.
The text was updated successfully, but these errors were encountered: