Permission denied. Rails could not complete the installation - ruby-on-rails

I tried to install Ruby on Rails in my user account. Atraves user terminal, do the following.
I find that the minimum requirements are met
I write the command line to install Rails (poor man).
I get the following error message at the beginning of the installation process:
Searching for binary rubies, this might take some time.
Checking requirements for debian.
Installing requirements for debian
user password required for /usr/bin/env PATH=/usr/local/bin:/usr/bin:/bin:usr/local /games:/usr/games:/home/user/.rvm/bin:/sbin:/usr/sbin:/usr/local/sbin apt-get --quiet --yes update:
Updating system.
Error running requirements_debian_update_system ruby-2.0.0-p247, please read /home/user.rvm/log/1380100570_ruby-2.0.0-p247/update_system.log
Requirements installation failed with status: 1.

Maybe your problem is related with sudoers file.
try edit this file:
vim /etc/sudoers
in this file should be your user name with permissions. For example:
your_user_name ALL=(ALL) ALL
try to add if it don't exists:)

I solved the problem by reinstalling ruby separately with the version I wanted to use.
Then install rails via gem install rails-v
then clear the gem that made ​​reference to the error and rerun bundle install . Then select the version I wanted to use installing ruby rvm rvm use default -v

Related

First Rails project: Problem installing yarn

I am trying to get started with Rails, following the guide at https://guides.rubyonrails.org/getting_started.html, but I'm running into problems.
I've got ruby, sqlite3, and rails installed as required, and then run
rails new blog
as indicated in section 3.2 of the tutorial. I get an error saying "Your user account isn't allowed to install to the system RubyGems.", but I can install the gems into ./vendor/bundle, as suggested (I don't have full root access on this machine).
So far, so good. But then
rails webpacker:install
is run by the process, which gives me the following message:
Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/
Of course, I went to that website and checked the instructions for my Fedora system and tried to follow them. The problem is again: I have limited root access, I cannot run the suggested commands; in particular, I cannot write to /etc/yum.repos.d/yarn.repo.
I also googled a bit, and what I could do is following https://developer.fedoraproject.org/tech/languages/nodejs/nodejs.html to install Node.js and Yarn (including setting the alias yarn for nodejs-yarn). But still, running
rails webpacker:install
says that Yarn is not installed.
Any help is greatly appreciated, I have to admit that I don't really know what I'm doing. Thanks!
On linux, the sudo command is the intended way to temporarily elevate user privledges.
wget https://yarnpkg.com/install.sh
sudo ./install.sh
That should get Yarn installed for you. The other problem it seems your having is installing ruby gems. You should be able to write to the vendor directory of your application by default, so make sure that you're doing this project in your /home/<MY USER NAME HERE> directory.

Rvm ruby Permission denied

I have installed rvm for multiuser,
when I am doing bundle install, it is giving me error,
linux:/var/rails_apps$ bundle install
ERROR: RVM Ruby not used, run `rvm use ruby` first.
linux:/var/rails_apps$ rvm use ruby
mkdir: cannot create directory `/usr/local/rvm/log/ruby-2.0.0-p247': Permission denied
I already did,
sudo chmod 777 /var/rails_apps/
Please suggest..
You have a multiuser installation of rvm - this is not recommended because of the troubles you can get with it (like yours).
Since you are already there this should fix it:
rvmsudo rvm get stable --auto-dotfiles
rvm fix-permissions system
Also make sure you are in rvm group - if not add yourself:
rvm group add rvm $USER
and log in to a new shell (log out and log back in).
In most of the cases rvm fix-permissions will resolve the problem for single user access but it fails in some cases while making other rvm commands thereafter. So do it with rvmsudo after the fix-permissions command consecutively as
rvm fix-permissions
rvmsudo rvm use ruby
For those who may have issues after running the commands shared on every thread out there, try opening ubuntu or the Linux environment you are working with as an administrator.
1 - Search for your app (in my case Ubuntu) using the search bar on the bottom-left of your computer's screen.
2 - if you don't see the option "open as administrator" on the right side, then right-click over the app's icon and you should see it then.
3 - Allow the app to make changes on your computer when prompted and then try the installation commands again.
4 - If that didn't work then try the commands shared in this or other posts, but always as administrator.

"The program 'ruby' is currently not installed" error after reboot

After the reboot which was required to update all the packages,
ruby -v
doesn't work. It says rails is not installed either, but I guess it should be the similar issue. when I do:
sudo apt-get install ruby
It says the newest version is already installed.
When I do:
dpkg -L ruby
I get the following output:
/.
/usr
/usr/bin
/usr/share
/usr/share/doc
[and other stuff..]
But I realized $PATH already includes /usr/bin:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
:/sbin:/bin:/usr/games:/home/ubuntu/.rvm/bin
May I know why I'm still getting the following error message?:
The program 'ruby' is currently not installed. You can install it by typing:
sudo apt-get install ruby
My .bashrc already has this too:
PATH=$PATH:$HOME/.rvm/bin
dpkg will be checking in a database that it maintains, whereas trying to execute ruby uses the PATH. If I recall correctly, Ubuntu has a bash handler configured to execute when any command is unresolvable; it seems that it just displays that generic message rather than checking with dpkg first.
It is possible that ruby has disappeared from your filesystem (or at least the directory it previously resided in), or that your PATH was changed.
What do you get if you execute "which ruby" and "where ruby"?
Lastly, Ubuntu can complain that a program cannot be found when it is present. This occurs when running a 64-bit version of Ubuntu, without the necessary x86 libraries installed, and trying to execute a 32-bit binary. However, I recall the error message being more along the lines of "file not found".

Getting a "bad interpreter" error when using brew

I'm getting this error when I try to run any brew command.
Holger-Sindbaeks-MacBook-Air:~ holgersindbaek$ brew help
-bash: /usr/local/bin/brew: /usr/bin/ruby: bad interpreter: No such file or directory
I have absolutely no idea on how to fix this and been searching for a long time without answer.
I got this error (much the same):
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 26: /usr/local/Library/brew.rb: Undefined error: 0
and fixed by the solution below:
Open brew.rb:
$ sudo vim /usr/local/Library/brew.rb
Change the first line's 1.8 to Current:
Before:
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0
After:
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0
Then brew works for me. Hope it helps if any other one got this issue. :)
If you get the error
Homebrew requires Leopard or higher. For Tiger support, see:
https://github.com/mistydemeo/tigerbrew
change the MACOS check from <10.5 to <10.
Tip by #TimCastelijns:
10.5 doesn't work because in comparison, it's higher than 10.10 (.1 vs .5). I added a check (and MACOS_VERSION != 10.10) instead of lowering from 10.5 to 10.
What you are getting means that Homebrew has not been able to locate the Ruby interpretter at the specified location.
Install Apple Developer Kit (comes with Xcode) which should be available to you as an optional install (or you can simply download it from Apple). This will install the Ruby interpreter for you.
In case you already have Xcode installed, this means that one of these things is happening:
You have a broken Ruby installation
You have more than one Ruby installation
Your installation has not been configured properly.
To identify if this is the first case, you can run ruby and see if you get any response.
If you don't, your installation is broken and you need to reinstall it. If you do, you then run which ruby. This should give you the absolute path to your Ruby executable. If this is anything other than /usr/bin/ruby then homebrew (and a bunch of other programs) will not be able to find it.
In case you have not ever tampered with your Ruby installation, you can check to see if /usr/bin/ruby already exists or not: cat /usr/bin/ruby. If you get No such file or directory, then you can easily create a symbolic link to your Ruby installation. Assuming the output of which ruby to by /usr/local/bin/ruby, you create the symbolic link this way: sudo ln -s /usr/local/bin/ruby /usr/bin/ruby and all should be well.
If there is a file at that location, you can run file /usr/bin/ruby to see if it's a real file, a symbolic link, or a corrupted file. If it is a symbolic link, your installation should be working, and since it's not, it probably is either a corrupted symlink or it's a bogus file.
You can remedy that by first deleting it (sudo rm /usr/bin/ruby) and then creating a new symlink to the correct location (sudo ln -s /usr/local/bin/ruby /usr/bin/ruby).
If non of the above works, you should consult the homebrew team after a clean install of Xcode and removing any traces of a Ruby installation on your system.
EDIT
Alternatively, as pointed out by the other answers, the issue might be because of a bad ruby version in your Homebrew settings.
A quick fix might be updating your Homebrew:
cd /usr/local
git pull -q origin refs/heads/master:refs/remotes/origin/master
If this does not help, you might want to get your hands dirty and manually fix the problem by:
Editing brew.rb from /user/local/Library/brew.rb
Changing /1.8/ to /Current/ in the first line, which will cause the hashbang to point to the current Ruby version as the executor
If this does not help, either, you can also modify the MACOS check and change it from 10.5 to 10 to avoid the infamous "Homebrew requires Leopard or higher" error.
DISCLAIMER
A bunch of thanks to other contributors in the answers below and their commenters. I am not committing plagiarism, simply aggregating the answers into one integrated article to help others.
Fix:
sudo gem install cocoapods
At the risk of oversimplifying things, try running
gem install bundler
I was transitioning my Ruby environment from RBENV to RVM and it worked for me.
This happened because I needed to update brew - in the updated version it already uses Current ruby
cd /usr/local
git pull -q origin refs/heads/master:refs/remotes/origin/master
This solved the problem
You need to change the path for Ruby.Framework
I solved it with commands as mentioned.
brew install cocoapods --build-from-source
brew link --overwrite cocoapods
If you have a lower version below Xcode 11, you have to remove it before you use the above commands.
Reference: Ruby Framework issue
None of the above worked for me, so I kept browsing and found this answer,
https://stackoverflow.com/a/24225960/1359088
which did fix brew for me. He says in step 1 to install XCode 6 command line tools, but doesn't say how; use this command:
xcode-select --install
I got the same issue when updated to MacOSX High Sierra & using Xcode 9 with that. High Sierra update 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
Restart Xcode & do fresh clean build it works for me.
Hope it helps!!!
After upgrading to macOS High Sierra, get it fixed with following commands:
sudo gem install cocoapods
In my case seems like fastlane installed incorrectly with brew install fastlane system didn't write correct path to fastlane. I fixed it with alias fastlane=~/.fastlane/bin/fastlane
I solved it with commands as mentioned.
1.) Uninstall your GEM.
gem unistall GEM
2.) Then Install your GEM.
sudo gem install GEM -n /usr/local/bin
I got bad interpreter: No such file or directory error when used xcpretty and xcpretty-travis-formatter on upgraded MacOS.
To solve it
gem install xcpretty
gem install xcpretty-travis-formatter
That is why I can recommend you to reinstall failed component gem install <name>
#For example error looks like
/usr/local/bin/xcpretty-travis-formatter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory
#use
gem install xcpretty-travis-formatter

sudo gem install rails- this doesn't give me a rails command for bash

I'm on Ubuntu. I type in sudo gem install rails. This works fine, installs railes and 7 other gems fine. Yet $ rails blog is saying this:
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Type
gem env
It will give you the installable directory where the bins of the gems are being installed. Something like this:
EXECUTABLE DIRECTORY: /usr/bin
Make sure this directory is in your path.
how did you install rubygems, as an admin, or as a user? if you installed it as a user, it may not have the bin directory in your path.
If I were you, (assuming you installed rubygems into your home folder), I would trash that installation dir (not sure where it defaults to, maybe ~/rubygems? or ~/.rubygems?), then run setup.rb from the rubygems tarball as admin (through sudo) I've done this at least a dozen times on ubuntu, and haven't run into the issue you are hitting.
If that isn't the case, could you please link to the blog post you were following?
Make sure your gem executable path is added to your system path so that the system can find the rails executable.
I know this is an old thread but the same error had me stuck. Make sure you add
source ~/.rvm/scripts/rvm to your .bashrc file

Resources