Skip to content
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

JRuby 1.6.4 shims seem broken #76

Closed
jmazzi opened this issue Sep 7, 2011 · 14 comments
Closed

JRuby 1.6.4 shims seem broken #76

jmazzi opened this issue Sep 7, 2011 · 14 comments

Comments

@jmazzi
Copy link

@jmazzi jmazzi commented Sep 7, 2011

Looks likes it's trying to execute bundle as a bash script

➜  helix git:(develop) ✗ rbenv |&  head -n 1
rbenv 0.2.0-pre
➜  helix git:(develop) ✗ rbenv version       
jruby-1.6.4 (set by RBENV_VERSION environment variable)
➜  helix git:(develop) ✗ bundle
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 9: require: command not found
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 11: version: command not found
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 13: syntax error near unexpected token `('
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 13: `if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then'
➜  helix git:(develop) ✗ 
@jmazzi
Copy link
Author

@jmazzi jmazzi commented Sep 7, 2011

This might provide some insight http://twitter.com/headius/status/111179885497679873

"Perhaps rbenv doesn't properly handle the fact that (ba)sh scripts can't shebang to other (ba)sh scripts."

@sstephenson
Copy link
Contributor

@sstephenson sstephenson commented Sep 7, 2011

Seems to be working fine here:

~$ rbenv version
jruby-1.6.4 (set by RBENV_VERSION environment variable)
~$ ruby --version
jruby 1.6.4 (ruby-1.8.7-p330) (2011-08-23 17ea768) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_26) [darwin-x86_64-java]
~$ gem install bundler
Fetching: bundler-1.0.18.gem (100%)
Successfully installed bundler-1.0.18
1 gem installed
~$ rbenv rehash
~$ bundle
Could not locate Gemfile
@jmazzi
Copy link
Author

@jmazzi jmazzi commented Sep 7, 2011

Weird. When I execute it directly it works fine


➜  helix git:(develop) ✗ bundle          
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 9: require: command not found
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 11: version: command not found
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 13: syntax error near unexpected token `('
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 13: `if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then'
➜  helix git:(develop) ✗ exec -a bundle /Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle
Fetching source index for http://rubygems.org/
@jmazzi
Copy link
Author

@jmazzi jmazzi commented Sep 7, 2011

Well, it works fine in zsh. Here is what happens I startup a default bash session


bash-3.2$ export PATH=$PATH:$HOME/.rbenv/bin
bash-3.2$ eval "$(rbenv init -)"
bash-3.2$ export RBENV_VERSION=jruby-1.6.4
bash-3.2$ bundle
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 9: require: command not found
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 11: version: command not found
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 13: syntax error near unexpected token `('
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 13: `if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then'
bash-3.2$ exec -a bundle /Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 9: require: command not found
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 11: version: command not found
/Users/justin/.rbenv/versions/jruby-1.6.4/bin/bundle: line 13: syntax error near unexpected token `('

@jmazzi
Copy link
Author

@jmazzi jmazzi commented Sep 7, 2011

Does your bundle look like this?


bash-3.2$ which bundle
/Users/justin/.rbenv/shims/bundle
bash-3.2$ cat `which bundle`
#!/usr/bin/env bash
set -e
exec rbenv exec "${0##*/}" "$@"
bash-3.2$ 
@sstephenson
Copy link
Contributor

@sstephenson sstephenson commented Sep 7, 2011

Yes, my bundle looks the same. I'm using bash, not zsh.

~$ $SHELL --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)
Copyright (C) 2007 Free Software Foundation, Inc.
@jmazzi
Copy link
Author

@jmazzi jmazzi commented Sep 7, 2011

RVM had this issue too, a while back https://gist.github.com/842807. Still investigating.

@jmazzi
Copy link
Author

@jmazzi jmazzi commented Sep 7, 2011

Changing the shebang to #!/usr/bin/env /Users/justin/.rbenv/versions/jruby-1.6.4/bin/jruby fixes this problem for me.

Interestingly enough, /Users/justin/.rbenv/versions/jruby-1.6.4/bin/jruby itself is also a bash script. I bet if this was a binary file it would work fine.

@sstephenson
Copy link
Contributor

@sstephenson sstephenson commented Sep 7, 2011

I'd like to figure out why it works for me but not you.

@jmazzi
Copy link
Author

@jmazzi jmazzi commented Sep 7, 2011

Is your /Users/justin/.rbenv/versions/jruby-1.6.4/bin/jruby a binary file or a bash script?

@sstephenson
Copy link
Contributor

@sstephenson sstephenson commented Sep 7, 2011

~$ head -n 1 ~/.rbenv/versions/jruby-1.6.4/bin/jruby
#!/usr/bin/env bash
@jmazzi
Copy link
Author

@jmazzi jmazzi commented Sep 7, 2011

Do you have any suggestions or things to try?

@jmazzi
Copy link
Author

@jmazzi jmazzi commented Sep 7, 2011

rm -f ~/.rbenv/shims/* && rbenv rehash fixed it for me. Previous to running this I ran rbenv rehash multiple times without any improvement.

I suppose it's possible that the ruby-build PREFIX bug yesterday could have caused some weirdness with my shims.

@jmazzi jmazzi closed this Sep 7, 2011
@sstephenson
Copy link
Contributor

@sstephenson sstephenson commented Sep 7, 2011

Weird. Glad you were able to fix it though. Thanks for helping me debug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants