I've an issue with gem file development, for example I'm creating a gem with executable command.
It all works well, I can run command, BUT I've issue that if I'm trying to run command inside another project folder it's USING Gemfile from this second project.
Can I somehow disable it?
I want only to use Gemfile (and .gemspec) from my gem, and not with folder where it was executed.
I have a gem github.com/igorkasyanchuk/rails_db (version in master branch is not released yet, so you need to build it locally), gem build ..., then gem install ..., and then go to your project dir and run "railsdb". When you run it, it's trying to load gems from local folder Gemfile.
Thanks
Igor
If you are using the rubygems-bundler gem, executing commands provided by a gem will load the bundle of your current directory. You can prohibit this from happening for a particular gem providing commands in various ways. One way:
export NOEXEC_EXCLUDE=my_gem_command
See https://github.com/rvm/rubygems-bundler for more information about rubygems-bundler.
Related
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
I am working on a Rails 4 application and one of the requirements is to have all of the Gems that normally go into the Gemfile brought in locally to the machine for use. This includes Rails and after looking at many google search results I am not able to find anyone talking about using the Rails gem locally on a Rails project.
My train of thought here is to clone the rails project from Github locally and then using the bundler config path to target that directory for rails, but I am not sure how well will that solution work or even if it will work.
I will appreciate any input here or if anyone has experience with this situation I will appreciate any insight.
The bundle install does that ?
If you want to install any gem to your project go to the project root on cmd
$ gem install gemname
Doing that you locally installed the gem afterwards you want to make sure its loaded to your project so you can run
$ bundle install
And simply like that your gem is installed. Hope that helps
If you have your project on github, then you can clone it using command.
git clone github-repository-url
And then from that project directory, run command
bundle install --path vendor
It will install all your rubygems into vendor directory.
I have a custom gem built as a .gem file that I am trying to reference from my Gemfile. I have placed the .gem file, along with the .gemspec, in the vendor/gems folder. My Gemfile has the following line:
gem 'umlgrader', '1.0.0', :path=>'vendor/gems'
When I run bundle install, it claims to have found the gem but it says it is "using" the gem, rather than "installing" it, even though the gem was not previously installed on my machine. When I try to run my app, I then get a NoMethodError when it tries to call any of the methods in the gem. Why isn't Bundler installing the gem?
I have gotten it to work by unpacking the gem in that directory and then editing the Gemfile as follows:
gem 'umlgrader', '1.0.0', :path=>'vendor/gems/umlgrader-1.0.0'
This solution is less than desirable. I would prefer to be able to install the gem using Bundler since I am trying to deploy the app to Heroku. I have already tried a lot of the solutions I have found online, but I am open to any suggestions.
EDIT:
Some of the other pages I have already gone through and tried:
Bundler: installing a specific .gem file
How to use Bundler with offline .gem file?
How do I specify local .gem files in my Gemfile?
I also noticed a lot of people suggest pointing to a Git repository containing the gem. I would rather not do this if I don't have to.
The Bundler documentation is somewhat cryptic on that topic, but that is the intended behaviour of Bundler. In order to use the path option you must unpack the gem at the desired location.
But that should be no problem for Heroku. After all, you are still using Bundler, even if the gem is already unpacked. It's just a step less in the gem installing process...
Without Docker
You need to clone the repository from github (or other source) to your custom folder. In example below the steps to reproduce how I use custom path to edit gems in a separeted folder:
In this case I use a custom_gems folder inside /bundle: mkdir /bundle/custom_gems.
cd /bundle/custom_gems.
git clone <gem-repository-source>. Is necessary to clone because if you copy from other folder in your computer probably some files are missed.
Set in your Gemfile: gem '<gem-name>', path: '/bundle/custom_gems/<gem-name>'.
Restart you application.
In docker-compose (or Docker)
With docker is little different, in this case I use a /gems folder inside my rails application folder: mkdir <my-app>/gems.
cd <my-app>/gems.
git clone <gem-repository-source>. Is necessary to clone because if you copy from other folder in your computer probably some files are missed.
Set in your Gemfile: gem '<gem-name>', path: '/bundle/custom_gems/<gem-name>'.
If you use docker-compose, you need to bind folders with volumes config, like below:
volumes:
- ./app/gems:/bundle/custom_gems
With this, your local folder (your machine) copy files inside ./app/gems to /bundle/custom_gems in Docker container.
Restart service.
If you NOT use docker-compose, you need add in Dockerfile some like:
ADD ./app/gems /bundle/custom_gems
I want to make a gem from rails source code and install the gem.
After clone the master repository of rails, I tried as follow.
$>gem build rails.gemspec
$>gem install rails-4.2.0.alpha.gem
It did not work. I also tried $>rake install which did not work either.
Looking forward your help!
There is a script in the root directory which builds from source and installs the gems. It's called install.rb. You can use it by running the following:
ruby install.rb 4.2.0.alpha
Note: At the time of writing this the arel gem needs to be built from source and installed separately before running the install script above. This is because the version constraints in rails are requiring a version of arel which has not yet been released onto rubygems.org.
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?