How to install gemfile on osx? - ruby

I am trying to install the following gem from the command line following the instructions:
https://github.com/maxdemarzi/neography
Executing:
gem 'neography'
Results in "Unknown command neography".
I have "bundle" gem installed from executing "gem install bundle".
What step am I missing? Does this have to be done for each individual project? Or is this supposed to install to environment?

The command you're looking for is gem install neography.
To create a Gemfile for your application, you need to look into the bundler gem's Gemfile. Basically, just create a file named Gemfile in your project root with a source and your list of gems and run the command bundle install.
A Gemfile that would work for you in this case is:
# Gemfile
source 'https://rubygems.org'
gem 'neography'

Related

Can bundler use locally installed gems when a custom source is specified

I have a project where we are building a custom gem which is hosted on a private gemserver (gemfury). This gem is a dependency in multiple Gemfiles where I need to run tests.
So I have a Gemfile that looks like this:
source "https://rubygems.org"
source 'https://gem.fury.io/custom/' do
gem 'my-custom-gem', '0.0.42'
end
gem 'aws-sdk-iotdataplane', '~>1.15.0'
gem 'bson', '~>4.4.2'
gem 'mongoid', '~>6.1.1'
.
.
.
I build and install the gem locally with rake install (which works fine) and then attempt to run bundle install on the above Gemfile.
I get the following error:
$ bundle install
Fetching gem metadata from https://gem.fury.io/custom/..
Could not find gem 'my-custom-gem (= 0.0.42)' in rubygems repository https://gem.fury.io/custom/ or installed locally.
The source contains the following versions of 'my-custom-gem': 0.0.1, 0.0.4
It is my understanding that if the gem is installed locally on the system, bundler should not attempt to fetch it from the source.
Is this correct?
If I remove the custom source block from around the gem line, it will use the local gem and the fact that the error message says "... or installed locally" really seems to suggest this should work.

bundle install - The Gemfile specifies no dependencies - Even though I'm in the directory that contains the Gemfile

I'm trying to follow a guide to use rspec for testing. I use bundle init to create the Gemfile. Then I tried to do bundle install (following the guide) to install all the gems. I made sure to be in the same folder containing the gemfile. However, I keep getting this:
The Gemfile specifies no dependencies
Bundle complete! 0 Gemfile dependencies, 1 gem now installed.
Use bundle info [gemname] to see where a bundled gem is installed.
My Gemfile (right after I did bundle init) looks like this:
frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "rails"
I use ruby 2.7.1.
Any help will be greatly appreciative.
I tried this step by step and I get this error only when I haven't specified any gem in my Gemfile. I guess the bundle init command create a Gemfile with gem 'rails' line is commented. Please verify your Gemfile and make sure you have added at least one gem into your Gemfile or check if gem 'rails' line is still commented out.

Bundler: Could not local Gemfile

I'm moving some ruby projects over to an Ubuntu machine, and am trying to install the dependencies.
I've installed ruby-full and the bundler gem. When I move to the project directory and type bundle install I get the error Could not locate Gemfile
I am in the correct directory, and the GemFile is there.
If I ls the current directory, I see:
etrax_connect.rb fujixml.bat fuji_xml.rb GemFile GemFile.lock generate_subject_xml.rb logging.rb prawn_functions.rb README.md samples sftp_connect.rb
Its RIGHT there.
The contents of my GemFile:
source 'https://rubygems.org'
gem 'listen'#file listening
gem 'nokogiri'#xml parsing
gem 'rake'#Globbing
gem 'net-sftp'
gem 'tiny_tds'
gem 'prawn'
I dont understand.
Rename GemFile to Gemfile, and also GemFile.lock to Gemfile.lock.

gem install with file system as source installs wrong gem

I have just started working with Ruby. I am trying to install a gem with local file system as source.
$gem source
*** CURRENT SOURCES ***
file:///home/fox/shared/
when i try to install 'bundler' gem it actually installs 'bundler-unload' gem as below.
$gem install bundler --bindir /usr/bin --no-ri --no-rdoc
Successfully installed bundler-unload-1.0.2
1 gem installed
the directory contains both the gems by the way.
bundler-unload-1.0.2.gem
bundler-1.10.6.gem
Is there anything that I am missing here. Why would it install the wrong gem?
I debugged the gem installer code and found the following.
First, the gem installer looks at the current directory to find the gems. It looks for *. It finds two gems (since i was running from the gems source directory) but sorts and reverse orders it and chooses the first one which is not the right gem. It does not do version check also when looking at the local directory. To workaround this i gave 'gem install bundler-1.10.6' which is working. By the way if i run 'gem install' from some other directory it is not able to find any gems from the 'file:' source.

Bundler install custom path issue

gem env shows
GEM PATHS:
/usr/local/share/gems
I would like to use bundle install --deployment --path=/usr/local/share/gems to install my bundled gems.
The problem is that the bundle install creates a folder ruby and puts the gems folder inside the ruby folder.
When this happens my ruby code is unable to find the gems in its default path.
Looks like I am missing some configuration parameter. Help please.
MaurĂ­cio Linhares comments in the question has resolved the issue.
When using bundler to install gems use bundle exec ruby. When the bundle install --deployment happens the path information goes into .bundle/config
bundle exec ruby path-to-ruby-script.rb
The above execution Will find the gems installed by the bundle command.
Alternatively, if you want to force installation to the system gem location, I believe bundle install --deployment --system will do what you want.

Resources