/usr/bin/ruby: bad interpreter: No such file or directory - ruby-on-rails

I am using capistrano for deployment of rails application. But while i am deploying my rails code into server i am getting following error.
The deploy has failed with an error: Exception while executing on host 00.00.00.00: bundle exit status: 126
bundle stdout: /home/rod/.rvm/scripts/set: /usr/local/bin/bundle: /usr/bin/ruby: bad interpreter: No such file or directory
/home/rod/.rvm/scripts/set: line 19: /usr/local/bin/bundle: Success
How can i solve this issue?

It's an issue related to ruby upgrade but bundle package path was old. To resolve it you should reinstall the bundler package again using gem.
Uninstall from system
sudo gem uninstall bundler
Install again
sudo gem install bundler

After MacOSX High Sierra update got this issue. High Sierra updates ruby gem to version 2.3 but xcpreety command of Xcode 9 still using Ruby 2.0 which is unable to find now & gives bad interpreter.
Just go to Terminal & run
sudo gem install xcpretty
insert your password it will update your xcpretty to ruby v2.3 & that will resolve the issue.
Restart Xcode & do fresh clean build it works for me.
Hope it helps!!!

Related

Rails. 'Bundle install' gives the 'bad interpreter: No such file or directory' error after Ruby version upgrade (Windows)

I've upgraded my Ruby version from 2.5.x to 2.6.x (and uninstall the 2.5.x version).
And now I'm getting the error upon bundle install (for my existing Rails project):
bash: /c/Ruby25-x64/bin/bundle: C:/Ruby25-x64/bin/ruby.exe^M: bad interpreter: No such file or directory
How can I tell the bundler to use the newer Ruby version?
OS Windows 10.
Ok, I've found a solution.
First of all, do not use git bash terminal and use the cmd.exe instead. That gave me info on why bundle install doesn't work (something's wrong with 'mimemagic' gem).
I've run bundle update and it installed all necessary gems and now everything works fine.

Rails Error Can't Find freedesktop.org.xml

I've had some issues starting a new RAILS project, where I'm getting an error that there is a missing file /usr/local/share/mime/packages/freedesktop.org.xml. There was a connection with the mimemagic dependencies, and I found this issue on GitHub about the mimemagic version and licensing - https://github.com/rails/rails/issues/41750
Wondering if anybody else ran into the issue, and could explain what is going on.
I'm using rbenv with ruby version: 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19], and rails 6.1.3
Here is the error message in the command line:
Installing railties 6.1.3
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/nico/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/mimemagic-0.3.7/ext/mimemagic
/Users/nico/.rbenv/versions/3.0.0/bin/ruby -I/Users/nico/.rbenv/versions/3.0.0/lib/ruby/3.0.0 -rrubygems
/Users/nico/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/exe/rake
RUBYARCHDIR\=/Users/nico/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/extensions/x86_64-darwin-19/3.0.0/mimemagic-0.3.7
RUBYLIBDIR\=/Users/nico/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/extensions/x86_64-darwin-19/3.0.0/mimemagic-0.3.7
rake aborted!
Could not find MIME type database in the following locations: ["/usr/local/share/mime/packages/freedesktop.org.xml",
"/opt/homebrew/share/mime/packages/freedesktop.org.xml", "/usr/share/mime/packages/freedesktop.org.xml"]
Ensure you have either installed the shared-mime-types package for your distribution, or
obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to the location of that file.
Tasks: TOP => default
(See full trace by running task with --trace)
rake failed, exit code 1
Thanks,
Nico
Found some links to shared-mime-info on the GitHub link I posted, and I solved the issue by running the command below and starting a new project:
brew install shared-mime-info
If you are on ubuntu OS you can run below command
sudo apt-get install shared-mime-info
If migrating data from an Intel Mac (or an M1 Mac running Rosetta 2) to an M1, note that mimemagic will cache the old directory, so in addition to brew install shared-mime-info, you'll want to run:
gem uninstall mimemagic
gem install mimemagic

How to resolve Rails issue- An error occurred while installing mysql2 (0.4.4), and Bundler cannot continue

you may get this issue while working on Rails 4.0 and above version along with Ruby 2.0 and above.
this is very common issue if you are going ahead with up gradation of Rails environment.
Steps to be follow-
For Windows System-
1.Download the the newest mysql-connector to c:\mysql-connector folder
2. gem install mysql2 -- '--with-mysql-include="C:\mysql-connector\include" --with-mysql-lib="C:\mysql-connector\lib"
Hopefully it will work for you.
For Ubuntu System-
1. open terminal (Ctrl+alt+T)
2. $ sudo apt-get install libmysqld-dev
Run bundle from your project directory
3. $ bundle
This will resolve the issue.We can also see the solution here.
https://randvblog.wordpress.com/2016/06/20/how-to-resolve-rails-issue-an-error-occurred-while-installing-mysql2-0-4-4-and-bundler-cannot-continue-make-sure-that-gem-install-mysql2-v-0-4-4-succeeds-before-bundling/
I got this issue resolved with following steps as-
open terminal (Ctrl+alt+T)
$ sudo apt-get install libmysqld-dev
Run bundle from your project directory
$ bundle
rails s
Now rails app is working fine.

error instatlling ruby on rails in mac

I was trying to install ruby on rails in mac.
I have Xcode and gcc compiler installed. When i tried to install git, it showed me the following error:
$:~ gem install git
$ ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Library/Ruby/Gems/1.8/gems/git-1.2.5
I changed the permissions of my 1.8 and gems directory. Still it is showing the same error. Any suggestions?
Have you tried with sudo? Try sudo gem install git.
Reference documentation: https://github.com/schacon/ruby-git#install

Rubygems do not install on OS X Lion

I used to have no problems at all with ruby, gems and all related stuff. But after installing X Code Developer Tools and upgrading to Lion the gems do not install.
I get the following error for every gem. This is the message for sqlite as an example:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/sqlite3-1.3.4 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/sqlite3-1.3.4/ext/sqlite3/gem_make.out
What went wrong? How to fix it?
I had to install the Command Line Tools in the latest Xcode-Version (4.3.1) and
sudo gem install rails
worked like a charm.
To install Command Line Tools, go to Xcode Preferences > Downloads or use the following command in terminal (thx #Purell):
xcode-select --install
I'm using Mavericks and Ruby 2.0.0 and I also got this error (mkmf.rb can't find header files) when installing gems. I solved this issue by creating some symbolic links in Terminal.
#First install developer tools again:
xcode-select --install
#Create symbolic link to Ruby include (updated for 10.9)
sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include
#Create symbolic link to config.h (updated for 10.9)
sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/2.0/Headers/ruby/config.h /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/config.h
I faced same problem while trying to install rails on my Lion. This is how i could solve it.
Install rvm
$ curl https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
Install osx-gcc-installer
https://github.com/kennethreitz/osx-gcc-installer
Installed new version of ruby
rvm install 1.9.3
Typed to following command to show the requirements
rvm requirements
To use an RVM installed Ruby as default, instead of the system ruby:
rvm system ; rvm gemset export system.gems ; rvm 1.9.3 ; rvm gemset import system.gems # migrate your gems
rvm alias create default 1.9.3
Installed rails:
sudo gem install rails
My Mac is now read for rails!! YAY!!
Not a direct solution to your problem, but I'd suggest using rvm to install fresh rubies and gems. That should take care of it.
While installing Rails I had the error :
can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
As i had already Xcode installed, I had just to install Command Line Tools to resolve this problem
You need to have XCode installed, it includes ruby.h as well as some other important files needed to compile other native gems.
Hello i'm sorry i can't test this answer but i would suggest to change the default search paths in your bashrc and extconf.rb since the Library files seem to be moved in Lion.
(P.S. if he wants to work with the default 1.8 Version, rvm would be an unneeded hassle)
Update to the latest version of xcode, that fixed the problem for me. Make sure xcodebuild is in your path.
running xcodebuild -version in a terminal window should output 4.2.1 (4.x at least).
After a OS-Update make sure that you do accept the X-Code license even when you have used command-line-tools before. Only then some header-files will be available. To accept the license you have to run X-Code once.
I just forgot to run it with the sudo command.
sudo gem install sqlite3
not:
gem install sqlite3

Resources