Installing gem without the internet availability - ruby-on-rails

Yesterday I tried to install rspec gem on a system which was not connected to internet, so this is what I did-
I downloaded the gem for rspec using the command gem install rspec and on command prompt its showing 5 gem inside the package - (system with internet conn)
diff-lcs-1.1.3, rspec-2.12.0, rspec-core-2.12.2, rspec-expectations-2.12.1, rspec-mocks-2.12.2
I copied the 5 folders from this location -
C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems
and pasted in the same path9system without internet connection),
when I updated the gem file with gem 'rspec' (computer without the internet connection) and restarted the server its still showing error.
I need to know if there is something else that updated during the installation which i am missing?
What other parts I need to add to make this rspec working on a computer without having internet connection.
PS- New to rails :)

To cache the gems execute bundle cache and it will save all the gem in vendor/cache directory.
When you you execute bundle install, it will use the cached gems.

Related

Trying to create a rails app but keeps failing to setup

I'm trying to create my first rails app. I'm on a Macbook Pro, so macOS.
I've been following this guide setting up rbenv, rails etc.
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-macos
Then I'm following a crash course on YouTube. In the terminal I try to create a new rails app
rails new foodlog
It starts to set up in the folder I made for it, but the following happens during setup
Bundler::PermissionError: There was an error whle trying to create
'/Users/myusername/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0/racc-1.6.0'.
It is likely that you need to grand executable permissions for all parent directories and write permissions for
/Users/myusername/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0'
This error continues repeating the same thing with things such as "strscan".
Then after it says
In gemfile:
rails was resolved to 7.0.3.1, which depends on
actionmailbox was resolved to 7.0.3.1, which depends on
net-imp was resolved to 0.2.3, which depends on
stscan
run bundle binstubs bundler
Could not find gem 'sprockets-rails' in locally installed gems.
rails importmap:install
Could not find gem 'sprockets-rails' in locally installed gems.
Run 'bundle install' to install missing gems.
rails turbo:install stimulus:install
Could not find gem 'sprockets-rails' in locally installed gems.
Run 'bundle install' to install missing gems
I've tried looking online, coming across similar but not exact issues. For example, one solution suggested doing bundle install in this directory, versus where the guide says do it in the home directory. So I do that and get
Bundle complete! 0 gemfile dependencies, 1 gem now installed.
Still doesn't do anything. I think the main culprit is the permissions error it mentions above? This is my first time trying to really do any development on the macOS and I'm sure there's just a misunderstanding somewhere regarding permissions, so if anyone can help that would be appreciated!
It is likely that you need to grand executable permissions for all parent directories and write permissions for
/Users/myusername/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0'
Your question does not mention, so I think you might have missed this suggestion. Make sure all directories have the executable permission

Ruby on rails 5; How to stop installing gem related files when I bundle install

I was making a chat app with ruby on rails 5.
I tried to implement image sending function in my app.
I followed the instruction of the below blog.(sorry in Japanese)
http://yamakichi.hatenablog.com/entry/2017/01/18/232856
1) bundleinstall below gems
gem "carrierwave"
gem "piet"
gem "mini_magick"
2) Create uploader
But it didn't work.
I removed gem "piet" by bundle upload after I deleted it.
At this moment, I realized that about 8000 unknown files were installed.
Below are examples of the file names installed.
vendor/bundle/ruby/2.3.0/bin/rake
vendor/bundle/ruby/2.3.0/cache/concurrent-ruby-1.0.5.gem
vendor/bundle/ruby/2.3.0/gems/concurrent-ruby-1.0.5/lib/concurrent/hash.rb
....
All the files start with "vendor/bundle/ruby/2.3.0".
If I delete this "vendor/bundle/ruby/2.3.0" file, I can remove every unnecessary files.
But next, I couldn't turn on local server.
It said,
"Could not find rake-12.1.0 in any of the sources"
"Run bundle install to install missing gems."
And if I bundleinstall, this 8000 file were installed again.
How can I avoid this problem?
The gem piet may be a dependency of another gem in your Rails project. When in doubt you can delete your copy of Gemfile.lock and run bundle again. It will auto-generate a new copy with the correct dependencies.
If you're working on a Rails project, it's totally normal for ~8,000 files to be installed since Rails itself relies on quite a few gems.
One way to cut down on the number of files installed by bundler is to skip the documentation within each gem. That can be accomplished by adding this to your local ~/.gemrc file
gem: --no-document

Create new Rails project with no internet connection (in Windows cmd) cause bundle error

My computer is behind a proxy, so I have no internet connection on my cmd, I've get RailsInstaller and installed it on my computer running Windows 7.
When I try to create a new Rails project by
rails new simple_cms
it works until command shows
run bundle install
it waits for a long time then I get this error
Fetching source index from https://rubygems.org/
Could not fetch specs from https://rubygems.org/
What else should I install, so I can create and work on Rails project without an internet connection?
My Ruby version is 1.9.3 and Rails version is 3.2.13
What bundle install command do is its install gems from https://rubygems.org/ to your system.
You could not run bundle install without internet connection.
You should have all the gems in you system which you used in your application.
If you have your gems installed, you can use bundle install --local. It is not require internet connection
First go to the app folder than run bundle install.
You can't run bundle install without internet connection, if your gems is not installed.

Gem not installing, showing connection error

When I try to install gem like bundler or rake after creating new gemset , its not installing
,but if i intall old version its working fine for me . Here are the error logs while installing gems
gem install rake
Fetching: rake-0.9.2.2.gem ( 7%)ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
too many connection resets (http://cachefly.mirrors.rubygems.org/gems/rake-0.9.2.2.gem)
This problem was caused by the cachefly server.
It seems that the folks over at rubygems.org disabled this mirror and then people's downloads were able to continue successfully.
There is a thread over at rubygems.org discussing this issue.
Use DevKit to install gem separately .
Edit :
Please check if you curl or wget that URL:
wget http://production.cf.rubygems.org/gems/rails-2.3.8.gem
curl -O http://production.cf.rubygems.org/gems/rails-2.3.8.gem
If not, then the problem is with your internet connection, http proxy or
provider.
If your browser works, might be due an HTTP proxy.
I had a similar issue when Capistrano was running a bundle install on a remote server. It seems to have been caused by a .rvmrc file in the project that I had not authorised.
So all I had to do to fix is was ssh into the server, cd into the project and accept the .rvmrc config file.
got similar problem
gem install rails
# after 5 minutes
WARNING: Error fetching data: too many connection resets (http://production.s3.rubygems.org/latest_specs.4.8.gz)
gem install rails --source 'https://rubygems.org'
# after 5 minutes
WARNING: Error fetching data: too many connection resets (http://production.s3.rubygems.org/latest_specs.4.8.gz)
but when I create Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.13'
and run bundle install it works
my location is London, UK
(also created topic on http://help.rubygems.org/discussions/problems/4494-too-many-connection-resets-when-gem-install-rails )
Always check if your computer isn't downloading because of administrator privileges (in cmd, shell, or rubymine).

Can't find data_warehouse ruby gem

I am working on a project and i was trying make it up and running in my local machine. But unfortunately the app is using a gem data_warehouse( found gem 'data_warehouse', '= 1.5.2' in environment.rb), I tried to look for this gem but can't find this gem, I was unable to run the application because of this. I never used data warehousing in ruby on rails either. I am slightly aware of the concept data warehousing. If any one aware of this gem please post the url for this gem or an alternate solution for avoiding this problem.
Neither can I. Now, assuming that you have a production machine where this gem is found:
You can see the installed gems with:
gem list
Go to production machine and run
gem env
There, you should see something like
REMOTE SOURCES:
http://gems.rubyforge.org/
http://gems.github.com/
After running the same command on your local computer, you can add the missing remote sources with:
sudo gem sources -a "http://missing_remote_sources"
and then try to install your gem.
If this doesn't work, you could also try a monkey-patch. Run
rake gems:unpack
on your production server. After this, you will be able to find your gem in the /vendor/gems folder. Copy the folder into your local vendor folder and it should work.
Btw, as it could just be a typo: have you tried commenting the line in the config file?

Resources