> bundle exec rubocop
The following RuboCop extension libraries are installed but not loaded in config:
* rubocop-rails
* rubocop-rspec
Where do I add these?
Add the following to the top of your .rubocop.yml file
require:
- rubocop-rails
- rubocop-rspec
Related
I would like to load a private gem in my rails app (I'm using docker and rails 5).
So first I add the gem in my gemfile :
gem 'my_gem', '0.1.4', git: "https://#{ENV['GITHUB_TOKEN']}#github.com/Orga/my_gem"
Then when I try to docker-compose build, this is what I get :
fatal: could not read Username for 'https://github.com': No such device or address
So I tried docker-compose run web bundle install. They ask me for my login. I've got no error, but the gemfile is updated as below :
GIT
remote: https://#github.com/Orga/my_gem
revision: 391ae38ff06dfd360eb42a09256f4a5463fba559
specs:
my_gem (0.1.4)
rails (>= 5.0.0.beta3, < 5.1)
roo (~> 2.1.0)
GEM
remote: https://rubygems.org/
...
This line seems really weird to me : remote: https://#github.com/Orga/my_gem .
So is it the good way to load a private gem ?
When I bundle install it asks for my login, so it will probably cause trouble in production right ?
EDIT
When I put direclty the token into the gemfile everything works.
So the env var is not called properly.
I tried :
.env
GITHUB_TOKEN=...
gemfile
gem 'my_gem', '0.1.4', git: "https://#{ENV['GITHUB_TOKEN']}#github.com/Orga/my_gem"
AND also tried
secrets.yml
development:
github_token: ...
gemfile
gem 'my_gem', '0.1.4', git: "https://#{Rails.application.secrets.github_token}#github.com/Orga/my_gem"
The best and most secure way of doing this is using bundle configuration
In your Gemfile, you should have:
source 'https://gem.fury.io/youraccount/' do
gem "your_service", "~> 1.0.0"
end
And then, if you need to authenticate, this can be achieved by running the following terminal command:
bundle config https://gem.fury.io/youraccount/ yourauthtoken
I hope this helps answer your question!
Ben
I tried installing rubocop by adding the suggested line to my Rails project's Gemfile:
gem 'rubocop', require: false
After running bundle, it installs and is visible in my Gemfile.lock.
However when running $ rubocop from my application's root I receive this error:
-bash: rubocop: command not found
I tried running $ which rubocop, and nothing comes up.
I've also tried running $ gem install rubocop, with no difference in behavior.
Here is the excerpt from my Gemfile.lock:
rubocop (0.27.0)
astrolabe (~> 1.3)
parser (>= 2.2.0.pre.6, < 3.0)
powerpack (~> 0.0.6)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
You have to run this command:
source ~/.bashrc
As right after running $ bundle command the gem was installed and its environment was set in your ~/.bashrc, but since you continued to use the old bash session you didn't get rubocop available as a command in your bash. Hence, either re-login in your bash(close and then open the terminal again) or run the command stated above.
I just updated my Gemfile and upgraded to rails 4.0.0 and ruby 2.0.0. I ran bundle install, bundle update, then pushed to Heroku. Then I migrated the db.
The app works on localhost but shows an application error on Heroku.
So I ran heroku run bundle update, which gave the following error:
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
If this is a development machine, remove the Gemfile freeze
by running `bundle install --no-deployment`.
You have added to the Gemfile:
* source: https://github.com/NoamB/sorcery (at master)
* source: rubygems repository https://rubygems.org/
* rails (= 4.0.0)
* sass-rails (~> 4.0.0)
* uglifier (>= 1.3.0)
* coffee-rails (~> 4.0.0)
* jquery-rails
* turbolinks
* jbuilder (~> 1.2)
* sorcery
* thin
* pg
* rails_12factor
* sdoc
* mailcatcher
* rspec-rails
* sqlite3
* foreman
* quiet_assets
You have changed in the Gemfile:
* sorcery from `https://github.com/NoamB/sorcery (at master)` to `no specified source`
This is what my .gitignore file looks like:
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global
# Ignore bundler config
.bundle
# Ignore the default SQLite database.
db/*.sqlite3
db/*.sqlite3-journal
db/development.sqlite3
# Ignore all logfiles and tempfiles.
log/*.log
tmp
.DS_Store
.sass-cache
.ruby-version
Procfile
.rspec
The error on Heroku is just a standard "Application error. An error occurred in the application and your page could not be served."
Here are my Heroku logs
I'm running a Rails 4 app and trying to get compass and susy running. I'm getting the following error:
File to import not found or unreadable: susy.
My gemfile group:
group :assets do
gem 'sass-rails', '~> 4.0.0.beta1'
gem 'compass-rails'
gem 'susy'
...
end
The only CSS line I have (_base.sass)
#import susy
I've run Bundle Install, and my app is using:
Using compass-rails (1.0.3)
Using susy (1.0.7)
Completely lost. I don't have a config.rb file for compass, but from what I gather it isn't necessary after like Rails 3.1/3.2. Any ideas?
You can found the solution in the compass-rails gem documentation:
You have to add the gem compass-susy-plugin instead of susy, like this:
# Gemfile
…
gem 'compass-rails'
gem 'compass-susy-plugin'
…
If you are using Rails 4 do not use group :asset, it has been removed, simply add the previous lines to the Gemfile.
Then run:
$ bundle
$ bundle exec compass install susy
These previous lines will generate files that require susy for you.
And finally add this to your application.rb:
# config/application.rb
config.compass.require "susy"
Everything was working just fine until, out of the blue, bundle update decided to 'update' to some very old versions of some gems. Any ideas? I'm baffled!
The Gemfile doesn't specify a version for the awry gems. eg.
gem 'rails'
I do...
bundle update
And(!)...
Using rails (0.9.5)
If I specify a version. eg.
gem 'rails', '~> 3.0'
Then it's ok.
Using rails (3.0.7)
Source 'http://rubygems.org'
Gem version 1.8.3, rvm version 1.6.14
Only some gems are wrong. mongoid is another. It's on 1.0.6. Thanks!
Problem solved. It was a gem conflict. I boiled it down to...
With just these two gems:
gem 'rails'
gem 'i18n'
You get i18n 0.6.0 (the latest) but rails is on 3.0.5 (3.0.7 is current latest).
And then with just these three:
gem 'rails'
gem 'i18n'
gem 'delayed_job'
You get:
Gems included by the bundle:
* actionmailer (0.6.1)
* actionpack (1.4.0)
* activerecord (1.6.0)
* activesupport (3.0.7)
* bundler (1.0.13)
* daemons (1.1.3)
* delayed_job (2.1.4)
* i18n (0.6.0)
* rails (0.9.5) <-- Yikes! that brings back memories!
* rake (0.9.0)
I've not looked deeper into how bundler's gem dependencies work yet, but that was what caused it. Interesting! And of course there's no need to include the i18n gem anyway, so removing that fixes things (or specifying gem versions).
Try this one.
Just update your bundler, May be of any-one of the older gem is conflicting with latest one, this type of issues arises.
'gem install bundler'
and then 'bundler install'
If you find again error, then delete GEM.lock file, then run bundler install. It may resolve the issue.