Unable to install gem with the proxy option - ruby-on-rails

Trying to solve this issue I have a solution telling that using the proxy option when installing gem will help.
I am executing the following line:
sudo gem install rails --http-proxy=http://rubygems.org/
but it give me the same error:
ERROR: Could not find a valid gem 'rails' (>= 0) in any repository
ERROR: Possible alternatives: rails
Could anyone tell what I am doing wrong?

The HTTP proxy isn't rubygems... if you espesify a proxy so... you have to put your own proxy... if you have not proxy... so don't put http-proxy... =)
Do first
REALLY_GEM_UPDATE_SYSTEM=1 sudo gem update --system
sudo gem install rails

In both question -also question from - Ruby is installed by package managers like Synaptic, Aptitude. Debian-like operating systems stricts installation of gems without using package manager. You may use REALLY_GEM_UPDATE_SYSTEM with installation of gems like, but not recommended:
gem install rails REALLY_GEM_UPDATE_SYSTEM=true
Instead of that, you should prefer using RVM or rbenv to get rid of package manager based installation

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.

rails offline installation in windows

I want to install ruby on rails in offline mode (i.e. without internet connection). So I downloaded railsinstaller-3.2.0.exe from http://railsinstaller.org/en and installed it. By the end, I had ruby installed but in order to have rails installed I ran
gem install rails
and faced these errors: (meaning command needs internet connection)
ERROR: Loading command: install (ArgumentError)
unknown encoding name - CP720
ERROR: While executing gem ... (NoMethodError)
undefined method 'invoke_with_build_args' for nil:NilClass
I mean is there any solution like downloading gems with another computer connected to internet and then copying files in the proper location in the installed directory of gems.
Please help me if you have any idea.
As said in a comment, it's a gem (lib) dependency issue.
You might want to look into installing the bundler gem library to manage dependencies for you, with bundler you would just have to run, bundle install and it would download all the required gems for you including any gem dependencies.
You can install bundler simply, just run
gem install bundler
Then in your rails project directory, just run bundle install.
Often to run a project (like rails for example) you might have to start it with
bundle exec rails start
To install Gem's on a non-internet connect computer you might want to refer to this answer on just that problem.
This is the website where you can find all available ruby gems. Ruby
gems download. Find the one you are interested and download it.
Then move the gem in a directory of your choice and cd into that from
the command prompt. I am using C:/ruby193/bin/pony-1.4.gem
Let's say that the gem we are interested in is the pony gem (smtp
email).
Just type gem install pony-1.4.gem
and you should get it installed manually unless you have a restricted
acc with not adequate administrative privileges.
You can also refer to the official documentation on the matter.

Gem error to install

I try to install rails but I am faced to the following error.
Has somebody any idea how to resolve it ?
C:\Users\Utilisateur>gem -v
2.0.14
C:\Users\Utilisateur>gem install rails
ERROR: Could not find a valid gem 'rails' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - no such name (htt
ps://rubygems.org/latest_specs.4.8.gz)
C:\Users\Utilisateur>gem install rails --source http://rubygems.org
ERROR: Could not find a valid gem 'rails' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - no such name (htt
ps://rubygems.org/latest_specs.4.8.gz)
Unable to download data from http://rubygems.org/ - no such name (http
://rubygems.org/latest_specs.4.8.gz)
First try to update ruby gems.
gem update --system
The issue most likely is with your internet connection.
If you see this issue again, try
gem install rails --source http://rubygems.org
You can add the not https source permanently like this
gem sources -a http://rubygems.org
Do you want to add this insecure source? [yn]y
I want to give you one more tip:
Don't develop rails on windows. Ruby and rails and many gems are very UNIXy in their ways. Install virtualbox and ubuntu on a virtual machine and run you development for there.
You might have proxy in your system. So use sudo http_proxy=http://host:port gem install rails.
I had the same issue but I ran the "Start command prompt with Ruby" as an administrator and tried the gem install rails and it worked.
I had to run 'gem install' as root to get this to work. I.e. 'sudo', which is less than ideal.
I suspect 'gem' has very poor error reporting and doesn't communicate the real cause from a permissions issue deep down the stack.
In my country for some strange reason rubygems.org domain is blocked. So a vpn was the solution for me.
My problem was I had configured a proxy in my network connection as #theBuzzyCoder said, so I simply changed my connection and it worked, I could install my gem (sass in my case)

'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.

Problem during SQLite3 installation on Windows XP

As shown in a blog I followed the instructions of setting up SQLite3 on my Windows, but after I pasted the necessary files in Bin folder of Ruby, which I downloaded from http://www.sqlite.org/download.html, I get the following error when I use the following commmands:
C:\gem install sqlite3-ruby --version=1.2.3
ERROR: http://rubygems.org does not appear to be a repository
ERROR: Could not find a valid gem 'sqlite3-ruby' (= 1.2.3) in any repository
Please help me out with this problem and suggest me alternate methods for gem installing SQLite3.
Thanks.
Check that you have the latest version of rubygems: gem -v executed in a command prompt should return 1.3.7. If it does not, you have several options (also explained on rubygems.org):
gem update --system
or
gem install rubygems-update
update_rubygems
Secondly, if you have the correct version and you are on a network with a proxy, you have to tell gem to use that proxy.
There are two ways to do that. First, you could do
gem install sqlite3-ruby -p http://yourproxyserver:port`
or you could define an environment variable
set HTTP_PROXY=http://yourproxyserver:port
and then this setting is saved (and you do not have to specify it explicitly anymore).
Hope this helps.
Try doing this: gem install sqlite3-ruby --version=1.2.3 --source http://gemcutter.org
If that does not work head over to http://gemcutter.org and download the particular version of the gem file, go to the destination to where you copied it to in the command line and install it locally using gem install sqlite3-ruby -l

Resources