ruby 1.92 bad interpreter: permission denied - ruby

New to Ruby and using RailsTutorial book to learn. I'm on Windows 7 machine using cygwin.
Anyway, I started using Ruby 1.8.7 (default on cygwin) and installed the gems, rails, git, etc. All working fine, but got to step to deploy app with Heroku and it required Ruby 1.9.2.
After research, I decided to uninstall Ruby 1.8.7 (through cygwin uninstall) and then compiled from source Ruby 1.9.2. I reran gems and installed rails again.
When I run rails -v though, I get -bash: /usr/bin/rails: /usr/bin/ruby.exe: bad interpreter: Permission denied.
Any ideas on how to get rails working again?
Thanks!
Here's output of gem env:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.12
- RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [i386-cygwin]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/local/bin/ruby.exe
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-cygwin
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.9.1
- /home/Philip/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/

Fix the permissions of /usr/bin/ruby.exe as said in the comment.
And if that doesn't help,
I'd say you re-install everything again but this time with Administrative privileges.
Open up a terminal with Administrative privileges and repeat the whole process.
BTW, How are you installing Rails on Windows?
Are you using Rails Installer for Windows by EngineYard??
If not, go take a look at the link above and railsinstaller-for-windows-EY-blog

I had the same issue with atlassian-stash gem under cygwin 2.3.1 x86_64 and ruby 2.2.3p173. I tried to fix the permissions for ruby.exe and all the script files, but even rwxrwxrwx permission didn't help.
The stange thing was that the scipt was running smoothly when called directly, but if it was a part of the git alias, it was getting me /usr/bin/ruby.exe: Bad interpreter: permission deined error.
I found that gem engine created some auxiliary files inside ~/bin folder. Removing those files helped.

Related

Running ruby gems on Windows

I am on Windows 7 and want to use http://hospice.io/. This requires Ruby gem librarian so I installed ruby 2.0 using http://rubyinstaller.org/ then downloaded RubyGems 1.8.25 from http://rubyforge.org/frs/?group_id=126 and updated (gem update --system). I installed librarian.
ruby setup.rb
gem install librarian
Now I am in the folder with my Vagrant box and want to do command librarian-chef but I get
'librarian-chef' is not recognized as an internal or external command, operable program or batch file.
I tried it when running ruby devkit/msys with the same result. Any suggestions how to run it please? I would guess there is a problem with PATH but when gem install works why doesn't librarian-chef work too?
gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.3
- RUBY VERSION: 2.0.0 (2013-02-24 patchlevel 0) [x64-mingw32]
- INSTALLATION DIRECTORY: C:/bin/ruby/lib/ruby/gems/2.0.0
- RUBY EXECUTABLE: C:/bin/ruby/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/bin/ruby/bin
- RUBYGEMS PLATFORMS:
- ruby
- x64-mingw32
- GEM PATHS:
- C:/bin/ruby/lib/ruby/gems/2.0.0
- C:/Users/Andrew/.gem/ruby/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
Also, might want to add that I started development on a Windows machine back in ruby 1.8.7 and through ruby 1.9.3 and then switched to Ubuntu 12.04. My development time probably cut in half or maybe even a quarter. I don't know if this has changed with Ruby 2+
I encourage you to look at having a dual boot with Ubuntu, the small investment in setup will save you TONS of time in dealing with making windows act like linux and give you the added benefit of setting up your development environment exactly like it will be in production if you will be running something like unicorn/nginx.

Passenger can't find bundler

I am desperatly trying to set up Redmine on my debian server. I managed almost everything (the interface works with webrick), but I want it to be accessable via dev.kaleydra.de, I wanted to solve this by using passenger+the apache2 module.
So now my current status is this message when I visit dev.kaleydra.de
Error message:
Redmine requires Bundler. Please install it with gem install bundler.
But bundler is definitly installed! (bundle install worked perfectly)
Some information:
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.9.1
- /root/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
I tried adding this to the enviroment.rb:
ENV['GEM_HOME']='/usr/local/lib/ruby/gems/1.9.1'
ENV['GEM_PATH']='/usr/local/lib/ruby/gems/1.9.1'
What I might notice is that I can't run
passenger-install-apache2-module
because it won't let me install libpq5 (Plesk uses a newer version and it specificly requests "libpq5 (= 8.4.13-0squeeze1)" with apt-get), but since passenger is showing the page makes it look like it already works...
I am kind of desperate, any clues?
I need your apache config file.
If you have all the needed gems installed but passenger still complain no gem found, please check if your 'apache user' has the privilege to access the gem folder.
e.g. your gems is installed by root but your apache-user is non-root, then this error occurs.
the solution is quit simply, if there's a account named root (e.g. in Centos) just these lines to your apache config file (httpd.conf or so)
User root
Group root
more details about "root, apache", see this post: https://serverfault.com/questions/103644/apache-user-root-access

How to install Vagrant as a $HOME gem, using Mac's Ruby interpreter (1.8)?

I've already asked about installing python packages at $HOME. It worked flawlessly.
Now, I'm planning to install Vagrant. It's a gem (a ruby package), and I would like to install it in my $HOME folder as well but I'm not used to it so I'm asking for help here.
I've already run,
sudo gem update --system
As followed by their mac tutorial. And when I try to install Vagrant using their recomendation:
gem install vagrant
I get:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/bin directory.
(It's strange that just gem install vagrant doesn't work, I followed the guide from Vagrant's official website in a vanilla installed Mac, never used Ruby here and I got the error. Specially when using sudo is not required.)
Ok. Using sudo is going to resolve it, but I don't want to install this gem system wide, I want to install them at $HOME like I did with pip - and I have no idea how I can do it without messing up with this mac machine. Can someone help me how to do it the best way? Which variables to I have to export, if I have to add ~/.gem to my $PATH, or something like that. (Did I already messed everything up when I used sudo gem update --system?)
Some people are suggesting to use rvm, but I think this is overkill since I'm not going to develop ruby applications against the system Ruby, I just want to run Vagrant. Of course, if there isn't another way, I'm going to use it.
My gem environment command outputs:
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.10
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-10
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/user/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
EDIT: I've found a tutorial, that says that I need just to add to my .profile:
export GEM_HOME=$HOME/.gems
export PATH=$GEM_HOME/bin:$PATH
Is it safe to use this approach?
Using the tutorial approach I posted it seems to work. I'm going to wait for more experienced ruby developers if this approach has any caveats in my scenario (I just want to run ruby applications, don't want to develop them) and them going to accept my own answer. :)
Transcripted tutorial:
Recommended: Installing Gems to Your Home Directory
Where possible, avoid installing gems into the global system. This
ensures that the gems that you install are easy to identify and
manage, and do not interfere with the global Ruby installation.
As of RubyGems 1.3, RubyGems will automatically install gems into the
directory specified by the GEM_HOME environment variable if the system
location is not accessible. You will see that directories are created
within your GEM_HOME directory to store gem files. This means that
RubyGems will do the right thing when managing packages, provided that
you do not run the gem utility with administrative privileges.
To do this, edit the .profile file in your home directory, and add or
amend it to include these lines:
export GEM_HOME=$HOME/gems
export PATH=$GEM_HOME/bin:$PATH
This takes effect the next time that you login or create a terminal window.
The presence of the bin subdirectory on your PATH enables you to use
any command-line utilities that are installed with your gem packages.

Problem running gems in OS X

I'm running Snow Leopard, and installed a custom built Ruby according to the guide here: http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard . My ruby binary lives in usr/local/bin/ruby and my gems are installed in /usr/local/bin/gem . My gem env looks like so:
RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
I think I may have borked the install since all actions taked on gems give the error:
ERROR: While executing gem ... (Errno::EEXIST)
File exists - /usr/local/bin/ruby
How do you edit the environment variables for the gem environment?
And for those of you on OS X and using ruby AND gems, what did you use to get yourself up and running?
I'm thinking of just nuking everything and starting anew.
It looks like your installation of ruby into /usr/local/bin is not the ruby that you're getting, which probably means /usr/local/bin/ is not in your PATH. If you'd like to run that ruby, try editing your .bash_profile to add /usr/local/bin like this:
export PATH=/usr/local/bin:$PATH
Alternately, you can add the path to a file in /etc/paths.d, which is the preferred method for adding paths globally on an OS X system.
I've tried things about three different ways, each with varying results. I have systems with the default install (/usr/bin), hand-built /usr/local/bin and also Mac Ports in /opt/local/bin.
By far, the simplest is to just use the built-in binary, which on 10.6.2 is ruby 1.8.7. In that scheme, gems are installed in /Library/Ruby/Gems. Second simplest is MacPorts (sudo port install ruby), third is the totally from source method you're describing above. Certainly there are good reasons people install from source, but unless you're trying to run ruby 1.9 or another version, you're best off using the built-in ruby 1.8.7.
Does the command "gem env" not report any gem paths? Mine reports a number of gem paths along with teh version of rubygems etc. that yours does not appear to be doing.
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.5
- RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-10
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/steveweet/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://gems.rubyforge.org/
You can edit the environment variables associated with gem by specifying them in your shell startup files, (.bashrc for bash). The relevant variables are all listed in the environment page of the gem web site. You will want to pay particular attention to GEM_HOME and GEM_PATH. You can check the current settings of these by typing echo $GEM_HOME at a shell profile
I would suggest that your best action at this moment in time may be to go back to your default ruby installation as provided with OS/X and then download and install rvm (The Ruby version manager) and then watch Ryan Bates screencast

Ruby Gems returns "command not found"

Ubuntu 9.10
Just installed newgem
gem install newgem
and when i try
newgem new_project
I get
adam#adam-ubuntu:~$ newgem newproject
newgem: command not found
Ive checked my path via echo $PATH
adam#adam-ubuntu:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/adam/.gem
and my gem enviroment
adam#adam-ubuntu:~$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.6
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/adam/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Im not hot with paths etc but all the gem directories listed above are on the path so how come it cant find the command?
Your $PATH variable needs to include the exact path to your Ruby's bin directory. Adding a directory to the PATH does not include it's subfolders. Try adding the bin directory via:
export PATH=$PATH:/home/adam/.gem/ruby/1.8/bin
or if you installed the gem using sudo:
export PATH=$PATH:/usr/lib/ruby/gems/1.8/bin
You might want to add this to your .bashrc file, so that you don't have to set this manually every time your open up a new bash.
(Just stealing #John Franklin's comment)
$ gem environment
Will tell you the EXECUTABLE DIRECTORY. Then put whatever that value is in your PATH like so (in your .bashrc or other shell config file).
export PATH="$PATH:/path/to/bin"
Reload your shell and you should then be able to use the installed gem.
If you use RVM (most do), then it will take care of this for you. In fact putting it in your path directly may conflict. You have to set a ruby to use though. Run one of these on the command line.
rvm use 1.9.3
or
rvm use --default 1.9.3

Resources