I installed rvm ruby and gem.
When I used gem to install rails, it's like this:
woyuxuxu123#ubuntu:~$ sudo gem install rails
[sudo] password for woyuxuxu123:
Successfully installed rails-5.1.4
Parsing documentation for rails-5.1.4
Done installing documentation for rails after 0 seconds
1 gem installed
But when I enter rails -v, I got:
woyuxuxu123#ubuntu:~$ rails -v
The program 'rails' is currently not installed. You can install it by typing:
sudo apt install ruby-railties
I tried some solutions, but did not work for me, such as
source ~/.rvm/scripts/rvm
Someone mentioned the path. Here is how it looks
RubyGems Environment:
EXECUTABLE DIRECTORY: /usr/local/bin
woyuxuxu123#ubuntu:~$ echo $PATH
/home/woyuxuxu123/bin:/home/woyuxuxu123/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/woyuxuxu123/.rvm/bin:/home/woyuxuxu123/.rvm/bin
What should I do?
I faced a similar issue for Rails 5.2 and Ubuntu 18.04. I had an already setup server with Ruby and Rails installed, but I couldn't access them.
The error output was:
The program 'rails' is currently not installed. You can install it by typing:
sudo apt install ruby-railties
The issue is simply caused by the rails executable not being globally accessible by programs.
Here's how I solved it
Note: If you are working on a production server, endeavour to make a backup of your database before trying out the solution below to avoid data loss.
For my case, my version manager was rbenv and not rvm
Re-install rbenv itself. Clone the rbenv repository from GitHub into the directory ~/.rbenv:
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
Next, add ~/.rbenv/bin to your $PATH so that you can use the rbenv command line utility. Do this by altering your ~/.bashrc file so that it affects future login sessions:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
Then add the command eval "$(rbenv init -)" to your ~/.bashrc file so rbenv loads automatically:
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
Next, apply the changes you made to your ~/.bashrc file to your current shell session:
source ~/.bashrc
Verify that rbenv is set up properly by using the type command, which will display more information about the rbenv command:
type rbenv
Your terminal window will display the following:
rbenv is a function
rbenv ()
{
local command;
command="${1:-}";
if [ "$#" -gt 0 ]; then
shift;
fi;
case "$command" in
rehash | shell)
eval "$(rbenv "sh-$command" "$#")"
;;
*)
command rbenv "$command" "$#"
;;
esac
}
If everything worked right, running the command below will display the versions of Ruby and Rails previously installed on your machine:
ruby -v
rails -v
Else, run a fresh installation of Ruby and Rails on your machine.
That's all
I hope this helps
Probably you forgot to add rvm script to your .bash_profile:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Try running rvm repair all and then restart your terminal.
Related
I am new to programming and trying to install Rails on Ubuntu 18.10, but I get the following error when running ~$ gem install rails. How do I avoid this error and install rails?
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # dir_s_mkdir - /home/bernardo/.gem/specs
I'm running Ruby 2.5.3p105.
Here are the steps that I took to install rbenv in ubuntu server
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv -v
rbenv install 2.5.3
rbenv global 2.5.3
rbenv rehash
ruby -v
gem install bundler
# inside rails application
bundle install
Explanation:
Line 1: clone rbenv project
line 2-4: enter rbenv path and settings to your bashrc
rbenv -v = check whether your rbenv is running correctly
then install ruby version (I checked above you running version 2.5.3)
rbenv global 2.5.3 (set version 2.5.3 in any folder paths)
rbenv rehash (after you set global / local make sure you do rehash)
Just go through the steps given in below link: https://gorails.com/setup/ubuntu/16.04
and make sure you install ruby using rvm and set is default ruby. Then install rails.
This will resolve your issue.
If still the problem is not resolved, then remove previously installed ruby and go through all the steps for ruby and rails installation.
Never install a gem with sudo command.
use
gem install rails
instead of
sudo gem install rails
Use sudo gem install rails May helps you.
I'm on MacOS Sierra
brew doctor says no problem
xcode/gcc is installed
My first problem is no response when I use curl.
And here is what I get when I trace the installation.
After the installation is complete, I restart my terminal and try and use 'source ~/.rvm/scripts/rvm', but I get an error 'No such file or directory'
I've tried to delete the directory and re-install a couple of times, but no luck.
EDIT: If I don't use -sSL, I get two lines of output, but still no luck: imgur.com/a/bxyLy
EDIT2: https://github.com/rvm/rvm/issues/3910 allows installation
Use rbenv instead of rvm, rbenv is most suitable than rvm.
Homebrew setup:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
rbenv setup:
brew install rbenv ruby-build
# Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile
# Install Ruby
rbenv install 2.4.0
rbenv global 2.4.0
ruby -v
I've got this problem with ruby versions. I've been looking for a solution, but none of the solutions I've found worked for me.
System is Ubuntu 13.10.
If I type
ruby -v
Then I got
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
But if I type
sudo ruby -v
Then I got
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
If I'm trying to change the version using sudo rvm use I'm getting:
sudo: rvm: command not found
Rvmsudo get's me this:
Warning: can not check /etc/sudoers for secure_path, falling back to call via /usr/bin/env, this breaks rules from /etc/sudoers. Run:
export rvmsudo_secure_path=1
to avoid the warning, put it in shell initialization file to make it >persistent.
In case there is no secure_path in /etc/sudoers. Run:
export rvmsudo_secure_path=0
to avoid the warning, put it in shell initialization file to make it persistent.
I've tried to type in those exports, but it didn't change anything. Typing them with "sudo", gives back "export:command not found".
I've already tried reinstaling everything, didn't help. It's a 6 hours now, that I can't find an answer.
I suspect that you do not have rvm correctly installed. To install rvm, please do as follows:
$ curl -L https://get.rvm.io | (sudo) bash -s stable --ruby -s stable --rails
$ curl -L https://get-git.rvm.io | bash
Single-User Install Location: ~/.rvm/
Multi-User Install Location: /usr/local/rvm
Then in Linux, try vim ~/.bashrc and at the end of it add below settings:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
This loads RVM into a shell session.
Then, reload to take effect:
$ source ~/.rvm/scripts/rvm
$ source ~/.bashrc # in Linux
$ source ~/.bash_profile # in MacOS
$ type rvm |head -1
if it shows rvm is a function then you have rvm installed successfully.
I am trying to use Jekyll with Vagrant and for some reason when I try to use the jekyll serve -w command it will start the server and build everything fine, but when I try and edit a file it will not rebuild.
Since version 2.0.0 [1] of Jekyll you can use --force_polling with --watch in order for Jekyll to pick up changes outside of Vagrant.
[1] https://github.com/jekyll/jekyll/blob/master/History.markdown
If you're on OS X with python v2.7.6 (check with python -V) you need to downgrade to 2.7:
brew update
brew install pyenv
echo 'if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi' >> ~/.bashrc
source ~/.bashrc
pyenv install 2.7
pyenv global 2.7
I moved to rbenv from RVM on Ubuntu Server.
When I use RVM, there is no trouble using bundle. After moving to rbenv I got a "command not found" error in Jenkins' execute shell.
I imploded and removed RVM and removed all RVM related lines from ~/.bashrc'. I still get this error after using:
rvm implode
rm ~/.rvm -rf
rm ~/.rvmrc
gem install bundler
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
. ~/.bashrc
rbenv versions
jenkins#testserver:~/jobs/myjob/workspace$ rbenv versions
* 1.9.3-p374 (set by RBENV_VERSION environment variable)
You seem to have installed rbenv correctly in your shell. However, if Jenkins doesn't source your ~/.bashrc as well, it won't be aware there's rbenv on your system. So in Jenkins, you have to ensure that your PATH for executing commands also includes $HOME/.rbenv/bin and $HOME/.rbenv/shims.
There's no need to use eval "$(rbenv init -)" in Jenkins; that's only useful for interactive shells.
#mislav's answer is probably right, but what actually worked for me was this:
sh '''
#!/bin/bash
export PATH=$PATH:/usr/local/bin:$HOME/.rbenv/bin:$HOME/.rbenv/shims
eval "$(rbenv init -)"
rbenv local
rbenv rehash
'''
In fact, I wasn't seeing rbenv as /usr/local/bin wasn't in my $PATH.
We are doing the following
sh '''
#!/bin/bash
source ~/buildmac-init
bundle update
bundle exec fastlane build
'''
in this buildmac-init file (among other variables):
...
export RBENV_ROOT=/usr/local/var/rbenv
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
...