How do I use this command? I am up to 1.2.4 Bundler but was unable to run the first part of this section from Hart'l's tutorial. It is simply:
cd first_app/
subl Gemfile
This are two commands.
You have to type it in your console/ terminal.
The first is:
cd thePathOfYourApp
cd = change directory
and then
subl Gemfile
means the Gemfile should be open with Sublime (a text editor)
Related
I installed jekyll, but surprisingly somehow osx doesn't recognise its installed.
$ sudo gem install jekyll
Password:
Successfully installed jekyll-1.2.1
Parsing documentation for jekyll-1.2.1
Done installing documentation for jekyll after 1 seconds
1 gem installed
$ jekyll
-bash: jekyll: command not found
gem environment ( - INSTALLATION DIRECTORY: /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0 )
$ cd /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/
echo $PATH
/usr/local/bin:/usr/local/sbin:~/bin:/usr/local/bin:/usr/local/sbin:~/bin:/Users/TheSpiritMolecule/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/TheSpiritMolecule/.rvm/bin
I have rbenv installed and the step I missed was to do an rbenv rehash after gem install jekyll. The rehash creates a link in ~/.rbenv/shims which is in included in $PATH.
Okay I had to check what exatly does the $PATH means, and for what it is.
The problem was simple, somehow my ruby installion directory wasnt in my $path variable.
Useful links: Mac OS X: Set / Change $PATH Variable
Okay so here is the thing how I solved it:
echo "$PATH"
gem uninstall jekyll
find / -name jekyll (to delete if there is any leftovers somewhere )
gem environment ( get EXECUTABLE DIRECTORY path )
nano $HOME/.bash_profile ( go to the end of document and insert a new line )
export PATH="/usr/local/Cellar/ruby/2.0.0-p247/bin:$PATH"
you can do this on a templorary way by just writing it in terminal and not saving it in your .bash_profile
Following steps solved my problem
gem uninstall jekyll
sudo gem install jekyll
Open ~/.bash_profile and add this code in the last line,
export PATH=$PATH:/usr/local/lib/ruby/gems/1.9.1/gems/jekyll-2.5.2/bin
Save and close the .bash_profile
Close and reopen the mac terminal, try running jekyll now, it should work
Hi People I am trying to install a gem file through command prompt on MAC using the following command "gem install filename" but whenever I try to execute the command I get the following error
WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /Users/hemmanshu/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
ERROR: Error installing frank-cucumber-0.8.14:
cucumber requires gherkin (~> 2.10.0, runtime)
every time I try to execute this command the same thing pops up.
You need to install gems with superuser privileges so you should to use
sudo gem install [gemname]
instead of
gem install [gemname]
U try with sudo. like "sudo gem install filename"
...Most of the time this is a PATH issue, Suppose you are using zshell as me, then add this line at the end of ~/.zshrc file
export PATH="$PATH:$HOME/.gem/ruby/2.1.0/bin"
If you are using bash as default shell then add this line to end of ~/.bashrc file
export PATH="$PATH:$HOME/.gem/ruby/2.1.0/bin"
For your case it will be like this:
export PATH="$PATH:$HOME/.gem/ruby/1.8/bin
Lastly don't forget to reload the shell by source ~/.zshrc incase of z-shell or source ~/.bashrc incase of bash-shell. I think this helps someone.
This might seem stupid, but I recently tried to install SASS and followed their instructions:
$ gem install sass
$ sass --watch [...]
So I followed along:
root#server:~# gem install sass
Successfully installed sass-3.1.15
1 gem installed
Installing ri documentation for sass-3.1.15...
Installing RDoc documentation for sass-3.1.15...
root#server:~# sass
bash: sass: command not found
Despite looking around like an idiot trying to find some simple way to run something like gem run sass or some other workaround to make it function, I am more or less at a loss.
It seems that Debian/Ubuntu drops ruby gems into /var/lib/gems/1.8/bin.
So the solution (at least for Ubuntu/Debian) is:
$ sudo -s
# echo 'PATH=/var/lib/gems/1.8/bin:$PATH' > /etc/profile.d/gemspath.sh
# chmod 0755 /etc/profile.d/gemspath.sh
...and then open a new shell session.
(This is fixed in Ubuntu 11.10.)
If you happen to have installed Ruby through rbenv, you'll need to execute the following command
rbenv rehash
On macOS I had to add the gem executable directory to the path.
Add these lines to your ~/.bashrc file, and reopen the terminal to refresh the env vars.
# gem
gembin=`(gem env | sed -n "s/.*EXECUTABLE DIRECTORY: \(.*\)/\1/p")`
export PATH=$gembin:$PATH
If you use macOS and you:
I don't know/care about Ruby.
I just want to run this program.
Why is this so complicated?
Then run:
~/.gem/ruby/*/bin/jekyll
where jekyll is the thing you just installed with gem install.
If you're trying to run a simple WEBrick server for your gem you can do the following after installation:
sass start
I have a small question. When I tried to install rubygems by following the code here:
wget 'http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz'
tar -vxzf rubygems-1.3.5.tgz
cd rubygems-1.3.5
ruby setup.rb
But when I try to do ruby setup.rb it says bash: /usr/bin/ruby: No such file or directory
.
So I tried which ruby and it says /usr/local/bin/ruby
Any ideas how I can fix this path thing?
i got this to work,i had to update my path on /root and /home for this to work.
vim .bash_profile in root and home
replace PATH with
PATH=$PATH:$HOME/bin:/sbin:/usr/bin:/usr/local/bin
and it's working now
By default, when you sudo gem install thegemname it will install executables into /usr/bin/
Is there a way to change this? For example, to install them into /usr/local/rubygems/bin (or any other path)?
The path doesn't seem to be hard-coded into the gemspec file, so I don't see why this shouldn't be possible (although I have very little experience with Ruby/Gems)
I'm adding this as an answer so that it is obvious when I run into this problem again :)
First, move all the bins in /var/lib/gems/1.8/bin/ to /usr/bin/. If you don't do this, then uninstalling or updating a gem will not remove the binary from the original bin directory.
You may also wish to remove the old path from $PATH
Next, edit ~/.gemrc and add (or update) the following line:
gem: --bindir /usr/bin
This overrides gem so that it always uses /usr/bin/ as the bin dir.
No need to update the path (especially messy for multiple-user machines).
See http://www.rubygems.org/read/chapter/11 and specify a ~/.gemrc which defines a gemhome variable.
For example:
gemhome: /usr/local/rubygems
You can also place this file in /etc/gemrc
Alternatively you can set the GEM_HOME env-variable:
$ export GEM_HOME=/tmp/gemtest
$ gem install bundler
$ ls /tmp/gemtest/bin/
bundle
Update (10 years later):
Andrey Rodionov below suggest using
gem: --bindir /usr/bin
On OS X, the executable directory is overridden to /usr/bin in the file /Library/Ruby/Site/1.8/rubygems/defaults.rb
# The default directory for binaries
def self.default_bindir
if defined? RUBY_FRAMEWORK_VERSION then # mac framework support
'/usr/bin'
else # generic install
ConfigMap[:bindir]
end
end
As a hackish work around, I changed /usr/bin to my desired bin location, which works correctly. There doesn't seem to be any way to override bindir from the ~/.gemrc config?
To install the executable to a desired directory, the command line option --bindir may be used:
sudo gem install thegemname --bindir /usr/local/rubygems/bin
Tried this option successfully with gem version 2.0.14.1.
For more command line options, run gem install --help on the command line.