bundle install error no such file or directory - ruby-on-rails

When i try install gem in rails app show my this error :
-bash: /usr/local/bin/bundle: /usr/local/opt/ruby/bin/ruby: bad interpreter: No such file or directory
Any idea as to why this is happening and how to fixed?
Thanks.

For me it was my path setting, as revealed by rvm
rvm list
output:
Warning! PATH is not properly set up, '/Users/user/.rvm/gems/ruby-2.2.6/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.2.6'.
rvm rubies
=* ruby-2.2.6 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Before checking my PATH, I ran the suggested command:
rvm use ruby-2.2.6
After that, the bundle command worked just fine. I then located where my PATH had got corrupted, and fixed that.

Related

Where can I change my Ruby gems directory path in

I am trying to use wicked_pdf and wkhtmltopdf, but everytime I run it I get the following error.
RuntimeError: Error: Failed to execute: ["/home/daveomcd/.rvm/gems/ruby-2.3.4/bin/wkhtmltopdf", "-q", "--encoding", "utf-8", "--disable-javascript", "--disable-internal-links", "--disable-external-link...
I think the issue is that it's executing from the /.rvm/gems/ruby-2.3.4/.. directory instead of my /.rvm/gems/ruby-2.5.1/.., but I can't seem to get it to switch tot he 2.5.1 directory. I'm using rvm and it's currently set to 2.5.1 as seen here. Where else would I need to check to change this? I've also uninstalled and install all of my gems and bundler, but no luck.
daveomcd#mcdonald-PC9020:~/rails_projects/bane$ rvm list
rvm rubies
ruby-2.3.4 [ x86_64 ]
=* ruby-2.5.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Oddly, I figured out the issue shortly after posting. My issue was I was using it in conjuction with Sidekiq. I needed to kill my sidekiq process and then restart the process. I guess it had started up when I was on a separate project. Thanks to anyone that took a look at my question.

Cannot install Ruby Gem Addressable v2.4.0

I am having problems with Ruby. When I try to install addressable, I get told I need ruby 1.9.0 or higher, but as you can see from my rvm list command I run 2.3.1.
Does anyone have any tips? am I doing something wrong? I've tried running the clean up, and reinstalling but I get the same error.
Any tips you can provide would be great! Thanks!
root#server1 [/]# rvm list
rvm rubies
ruby-2.3.1 [ x86_64 ]
# Default ruby not set. Try 'rvm alias create default <ruby>'.
# => - current
# =* - current && default
# * - default
root#server1 [/]# gem install addressable -v '2.4.0'
ERROR: Error installing addressable:
addressable requires Ruby version >= 1.9.0.
root#server1 [/]#
First run rvm use ruby-2.3.1 then gem install addressible.
To not have to run this command first, run rvm alias create ruby-2.3.1. You may have to run bash after that to load the changes. Sometime's it's needed to either run /bin/bash --login or change the terminal preferences to login shell in order for RVM commands to work.
I think you may be using the "system" ruby. This will be obvious when you run ruby -v. It is also evidenced by the fact that your rvm list output does not list a Ruby as the "current" Ruby. So rvm will have a newer Ruby, but it will not be used.
It's possible that creating the default Ruby for rvm will result in that Ruby being loaded whenever you open a terminal.
Also, the terminal needs to be a "login shell", but if this is a problem you should see a message to that effect.
So I suggest doing the following, which should only need to be done once:
rvm default ruby-2.3.1
...then opening a new terminal and seeing if your gem command works correctly there.

RVM error installing rubygems on Ubuntu

I have an ubuntu machine and I am trying to install rubygems using RVM by following this guide:
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
When I run the command rvm rubygems current or even the command rvm rubygems latest I get the following error:
fl4m3ph03n1x: ~ $ rvm rubygems current
system - #downloading rubygems-2.4.8
system - #extracting rubygems-2.4.8.....
system - #removing old rubygems.........
$LANG was empty, setting up LANG=en_US.utf8, if it fails again try setting LANG to something sane and try again.
system - #installing rubygems-2.4.8.
Error running 'env GEM_HOME=/home/fl4m3ph03n1x/.rvm/gems/system#global GEM_PATH= /home/fl4m3ph03n1x/.rvm/rubies/system/bin/ruby -d /home/fl4m3ph03n1x/.rvm/src/rubygems-2.4.8/setup.rb --no-document',
showing last 15 lines of /home/fl4m3ph03n1x/.rvm/log/1437602750_system/rubygems.install.log
[2015-07-22 22:05:50] /home/fl4m3ph03n1x/.rvm/rubies/system/bin/ruby
current path: /home/fl4m3ph03n1x/.rvm/src/rubygems-2.4.8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/fl4m3ph03n1x/.rvm/bin
command(7): env GEM_HOME=/home/fl4m3ph03n1x/.rvm/gems/system#global GEM_PATH= /home/fl4m3ph03n1x/.rvm/rubies/system/bin/ruby -d /home/fl4m3ph03n1x/.rvm/src/rubygems-2.4.8/setup.rb --no-document
env: /home/fl4m3ph03n1x/.rvm/rubies/system/bin/ruby: No such file or directory
At first I thought the error was due to the --no-document flag, but after reading and trying this discussion on github, nothing changed.
I also checked this stackoverflow discussion but it doesn't seem to be applicable to my case because I have a fresh installation (no manually installed packages nor anything).
Over all I tried using commands like rvm get head and rvm stable but nothing seems to work.
What am I missing? Could this be a permission's problem somehow?
EDIT:
This is the result of rvm list:
rvm rubies
ruby-2.2.1 [ x86_64 ]
# Default ruby not set. Try 'rvm alias create default <ruby>'.
# => - current
# =* - current && default
# * - default
I had ruby installed, but turns out it was not set in rvm.
To fix this first I tried using rvm use ruby --default, but I got the infamous "rvm is not a function" error.
To fix this, first run bash --login and then then rvm use ruby --default.
Once these steps are complete you can proceed with rubygems installation.

Gemfile loading twice / rvm --default not working

Gemfile
Every time I'm running a command in my terminal that requires my Gemfile, it gets loaded twice. Such as rails server, rails console, bundle install, ... etc
Adding puts "gemfile loading?"at the end of my Gemfile cleary show that:
Output from my shell:
gemfile loading?
/Users/AnsPoluke/.rvm/gems/ruby-1.9.3-p362#global/gems/bundler-1.2.3/lib/bundler/runtime.rb:197: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
gemfile loading?
/Users/AnsPoluke/.rvm/gems/ruby-1.9.3-p362#global/gems/bundler-1.2.3/lib/bundler/runtime.rb:197: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
I have no idea what the error code is telling me... Bonusquestion! ;)
RVM
Additionally, every time I open a new shell I have to reconfigure what ruby version I'm using, even though I have used rvm --default use ruby-1.9.3plenty of times.
running rvm list in any new shell
ruby-1.9.3-p327 [ x86_64 ]
=* ruby-1.9.3-p362 [ x86_64 ]
The default is recognised correctly, but running ruby -v outputs
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
Using:
oh-my-zhs
rails 3.2.10
rvm 1.17.6
Somehow I feel that these problems may be linked together... Appreciate your help!
rails is known from multiple execution of bundler, in this case it can be extra call caused by rubygems-bundler you can disable it temporarily with:
NOEXEC_DISABLE=1 rails s
then check if rails is properly detecting double bundle exec with:
NOEXEC_DISABLE=1 bundle exec rails s
if that works open a ticket for rubygems-bundler here: https://github.com/mpapis/rubygems-bundler
as for the default ruby issue - it is known problem with oh-my-zsh => https://github.com/robbyrussell/oh-my-zsh/pull/1359 you need to remove hardcoded PATH= with no $PATH from ~/.zshrc
You can also try latest version of RVM, it has a trick to extra fix and sort PATH ... but it's only a hack to the real problem is the hardcoded PATH= in ~/.zshrc.

Cannot install RVM . Permission denied in /usr/local/rvm

Based on my previous thread : RVM installed by Ruby not working? where i had installed RVM using the root user, I then had to entirely remove the RVM install and now i am installing as a user.
So i did :
Create a new user by doing : useradd newuser
Follow the instructions on the RVM website and execute the command : bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
Now, i get the error : mkdir: cannot create directory `/usr/local/rvm': Permission denied
The new user i created does not have access to this directory. I manually tried creating the folder but the same error. Please help.
EDIT : The original problem occured because i did not restart the terminal and it was still using the old settings.
Now, I got a new problem : After installing RVM, i cannot run it and it gives me an error : rvm command not found.
Here is the output of my ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
And here is output from ~/.bashrc file
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
mkdir: cannot create directory `/usr/local/rvm': Permission denied
If you've run the rvm installer as root previously, remove /usr/local/rvm and /etc/rvmrc.
RVM is easy to install, but you are making it harder by trying to mix and match installation types. You do NOT need to create a new user. When run, RVM will create a directory in your home directory: ~/.rvm, and install everything inside it. That means you will have all the correct permissions. You do NOT need to be running as root, you do NOT need to use sudo. I'd recommend closing all your command-lines and open one fresh and start at your home directory. If you are running as root, log out, and log back in to your normal account. For a single-user install you do NOT need to be root.
For a single user, using RVM as their Ruby sandbox, use the single-user installation docs. Follow ALL the instructions on that page, INCLUDING the "Post Install" section.
Close your terminal window, and reopen it. If you have correctly followed the instructions above, typing rvm info should spit out a template of what is to come once you install a Ruby instance. If you see nothing output, or get an error, then retrace your steps in the "Post Install" section, and go through the "Troubleshooting" section. Most of the problems people have occur because they didn't bother to read the directions.
Once RVM is installed, type rvm notes and read what dependencies you need to install. If you do not add those files your Rubies installed will be missing functionality. They will work, but some of the creature comforts you'll hear about won't work and you will wonder why.
After installing the dependencies you should be in good shape to install Rubies. Type rvm list known for all the Rubies RVM can install. If you want 1.8.7 type rvm install 1.8.7, and, similarly, rvm install 1.9.2 for Ruby 1.9.2. If you want a particular revision you can add that, based on the ones in the list.
It's important to periodically update RVM using rvm get head. That will add features, fix bugs, and tell RVM about new versions of Ruby it can install if you request.
After installing a Ruby, type rvm list and it should show up in the list, looking something like this:
rvm rubies
ruby-1.8.7-p334 [ x86_64 ]
ruby-1.9.2-p180 [ x86_64 ]
Type rvm use 1.9.2 --default to set a default Ruby that will be sticky between logins. Use the version of whatever Ruby you want to default to if 1.9.2 doesn't float your boat. Once you've defined a default it should look something like:
rvm rubies
ruby-1.8.7-p334 [ x86_64 ]
=> ruby-1.9.2-p180 [ x86_64 ]
Before you begin installing gems into a RVM-managed Ruby, read "RVM and RubyGems ", in particular the part that says "DO NOT use sudo... ". I repeat. Do NOT use sudo to install any gems, in spite of what some blog or web page says. RVM's author knows better when it comes to working with RVM controlled Rubies. That is another mistake people use with RVM, again as a result of not reading the directions.
On Mac OS, you'll need the latest version of XCode for your OS. Do NOT use the XCode that came with Snow Leopard on the DVD. It is buggy. Download and install a new version from Apple's Developer site. It's a free download requiring a free registration. It's a big file, approximately 8GB, so you'll want to start it and walk away. Install XCode, and you should be ready to have RVM install Rubies.
Finally, RVM installs easily, as will the Rubies you ask it to install. I have it on about four or five different machines and VMs on Mac OS, Ubuntu and CentOS. It takes me about a minute to install it and another minute to configure it and start installing a new Ruby. It really is that easy.
I had the original issue reported in this question, "mkdir: cannot create directory `/usr/local/rvm': Permission denied" when trying to install rvm.
This is my scenario and how I solved it - maybe this will help others with this same issue.
I have Ubuntu 11.04 installed on a laptop, I only have 1 user, the one I created at install time, named nathan. When I would try to install rvm as nathan, the rvm installer saw me as root and kept trying to install rvm globally, but since I wasn't really root, it couldn't get access to create directories in /usr/local/rvm.
I'm far from an expert with Ubuntu, so I'm sure there are easier/better ways to accomplish the things I did (and I would love to learn about them), but this worked for me:
I created a new user called rubydev
I logged in as rubydev, opened a terminal and typed:
rubydev~$ bash < <(curl -B http://rvm.beginrescueend.com/install/rvm)
rvm installed correctly and I logged out of rubydev
Signed back in as nathan, opened a terminal and typed "su" (you could do all this with sudo, I am lazy)
After successfully getting root, I typed the following commands:
root: /home/nathan# cp -R /home/rubydev/.rvm .
root: /home/nathan# chown -R nathan .rvm
root: /home/nathan# chgrp -R nathan .rvm
root: /home/nathan# exit
nathan~$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
nathan~$ echo 'export rvm_path="/home/nathan/.rvm"' > ~/.rvmrc
nathan~$ source .bash_profile
At this point, rvm was correctly installed under my home directory. To verify I typed:
nathan~$ type rvm | head -1
rvm is a function (if you don't get this response, something else is wrong)
Read the notes and installed any dependencies
nathan~$ rvm notes
I installed some rubies
nathan~$ rvm install 1.8.7-head
nathan~$ rvm install 1.9.2-head
Verified install
nathan~$ rvm list
rvm rubies
ruby-1.8.7-head [x86_64]
ruby-1.9.2-head [x86_64]
nathan~$ rvm use 1.9.2
using /home/nathan/.rvm/gems/ruby-1.9.2-head
nathan~$ rvm list
rvm rubies
ruby-1.8.7-head [x86_x64]
=> ruby-1.9.2-head [x86_x64]
Finally, I edited the preferences on the terminal itself to ensure the "Run command as as login shell" under the "Title and Command" tab was checked. It seems .bash_profile isn't otherwise processed.
I removed the rubydev user I created in step 1.
With all of that, I have a working rvm under Ubuntu 11.04 using my preferred username.
I solved this by adding
export rvm_path=~/.rvm
to ~/.bash_profile
If you first installed RVM as root and then uninstalled it. And now you are trying to install it as a non sudo user and you're getting the following error:
mkdir: cannot create directory `/usr/local/rvm': Permission denied
Make sure that you have logged out of the root session before trying to install under the user.
If you installing RVM as a user then the RVM folder should be generated in your home directory:
~/.rvm
Where there should be no permissions problems at all.
I would suggest it is picking up some old config that is left over from your system installation.
Ensure there is no /etc/rvmrc or $HOME/.rvmrc file left over because it might be using previously initialised variables from these files to construct an incorrect installation path.
if we look at this section of the bash script:
if [[ ${rvm_ignore_rvmrc:-0} -eq 0 ]]; then
for file in /etc/rvmrc "$HOME/.rvmrc " ; do
if [[ -s "$file" ]] ; then
source $file
fi
done
fi
It is trying to find one of these files, if it finds one if will run it possibly initialising rvm_path which will subsequently not be set as $HOME/.rvm by this command
rvm_path="${rvm_path:-"$HOME/.rvm"}"
I had the same issue. When I tried to create a gemset I would get a permission denied error. I just forgot to run the "rvm use 1.8.7" command first. After that I was able to create and use the gemset without any problems.
In lasts versions of rvm you need remove /etc/profile.d/ also.
This happen often if you try to install as root and then try again as a regular user.
Hope this help.
Look for file rvm.sh below /etc directory (It may be in /etc, or /etc/init.d).
Also, try some grep rvm /etc -r, so you can find some files/lines which prevent you from installing rvm in your $HOME dir.
For me running
__rvm_unload
Worked first, this was due to the fact that I had rvm installed as for multiuser.
If you installed rvm as root and you are getting permission denied issues (maybe you are deploying with capistrano as a non root user) then you could try rvm fix-permissions after doing things like rvm install 2.2.2 as root and creating a gemset as root.
Scott Bartell's solution worked for me. i am on a Digital Ocean premade image, where they had already setup rvm as root.
1. deleted /etc/rvmrc .
2. added export rvm_path=~/.rvm to ~/.bash_profile
3. logged out of ssh session to virtual machine
4. logged back in and presto!
would have commented but rep is 3 points too low :)

Resources