Why doesn't gem install bundler work? - ruby-on-rails

I am trying to deploy an application via Github pages, and based on this tutorial that I am watching, I need to install bundler first.
When I type in the command gem install bundler, I get the error:
While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
I do not have rbenv downloaded and I don't know how to. I also do not fully understand the concept of gems.
How can I bypass this issue?

Try 'sudo gem install bundler'

Related

Can't install ruby on rails in ubuntu gnome 15.10

I am trying to install ruby on rails. I'm at version 2.3.0 for ruby and gem version of 2.5.1.
When I run the command gem install rails I get an error that says:
ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /usr/local/lib/ruby/gems/2.3.0 directory.
How can I fix this?
gem install tries to put files in "system-wide" directories. These are protected, such that only the root user can write into.
You have at least three possibilities:
sudo gem install ..., this will write the gem files into /usr/local/lib/ruby/gems/2.3.0
gem install --user-install, this will install the gem "locally" in your users home directory
apt-get install ruby-rails (not sure about the package name), which will install the ruby on rails version maintained by your distributions maintainers (Canonical).
install and use rvm or rbenv (and there might be other options). Afterwards gem install will usually just work and install the gems for your user only
While the rvm setup might be a tiny bit confusing for newbies, I recommend using that approach. It will make updating and installing ruby, gems and different versions of it really easy.

uglifier gem load error / download node.js?

I am getting started with Ruby on Rails, and following the steps at InstallRails... I have created the sample_app on the desktop, and now I cannot create the server.
My command
$ rails server
is answered with the following
...There was an error while trying to load the gem 'uglifier'. etc
I have read several threads here and elsewhere, such as this one and this one... In the latter there seems to bea solution, which I can't understand.... I cannot download node.js! or nodejs? What is my command and directory in Gitbash to download it?
It requires JS runtime.
Just install gem therubyracer for the JS runtime.
In the default rails Gemfile,uncomment the line for the gem 'therubyracer' which is commented out.If you dont find it add the gem to your Gemfile like
gem 'therubyracer'
Then run
bundle install
The gem will be installed and it should work.
Otherwise you can install node.js.
For ubuntu
sudo apt-get install nodejs
For mac
brew install nodejs

Can't Install Bundler, no permissions

Im using Ubuntu 15.10. This is the code I write in the terminal
gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.1.0 directory.
Why is it trying to install it there? of course it doesn't have permissions to install it in the root directory. If I try the same command like this sudo gem install bundler it works. But it is not supposed to be installed as sudo, it gives me problems when creating a new Rails app. What should I do?
You should probably start by running gem env and look at your default environment.
You can change the default installation directory by exporting a different GEM_HOME:
export GEM_HOME=$HOME/.gem/

Failure to install ruby gems with rbenv

I can't install any Ruby gems. I am using rbenv and when I use gem install rails, I get a permission error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory
I have been trying to install Rails for days now, even with RVM.
I am pretty sure the problem lies with my $PATH but I do not know how to change this.
I am running Ruby version 2.0.0p247.
Can you try gem update --system, and try to gem install again, if it fails, post your log.

'gem install' and 'sudo gem install'

I've got an issue installing gems on my mac (os 10.6).
I used to be able to run
gem install <gem-name-here>
but after updating something, it could be the version of gem I'm using, but it's unlikely, I now get the error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/bin directory.
On the face of it, it looks like my 'GEM_HOME' isn't set. If so, why has this been unset, and how can I change it back?
Secondly - when I run
gem list
I see all gems - including those in ~/.gem, but when I run:
gem server
I only see gems in /usr/bin... strange huh?
Any help would be great to resolve this - I dont like using sudo to install gems constantly.
Install RVM.
Profit!
It really is that simple. In addition, you will be able to install and easily switch between different Ruby versions and sets of gems with a single command. It will all be installed in ~/.rvm (by default) and you won't need to use sudo to install gems.
Have you tried doing $bundle update after installing the gems that you wanted?
Follow the instructions in this guide:
export GEM_HOME=$HOME/.gem
export PATH=$GEM_HOME/bin:$PATH
gem install <gem-name-here>
If you were already doing this, completely delete the ~/.gem directory and try again.

Resources