Can't seem to install rubocop gem using Rails 4 - ruby-on-rails

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.

Related

Could not find nokogiri-1.11.4-x86_64-linux in any of the sources - Macbook M1 running Docker

I'm running a Rails app and getting this error whilst running in Docker.
There are no results on Google for what the cause might be.
The gem doesn't appear in my Gemfile so it must be a dependency of Rails or another gem.
The previous error I was getting was:-
Could not find 'nokogiri' (>= 1.5.9) among 144 total gem(s) (Gem::MissingSpecError)
To resolve this, I added gem install nokogiri to my Dockerfile, which now gives me the title error. Any ideas?
When you add gem install nokogiri in your Dockerfile, it will install linux compatible nokogiri (1.13.3-x86_64-linux) and will add that to your Gemfile.lock.
When you run rails on your mac, it will need mac compatible nokogiri (1.13.3-x86_64-darwin)
Here is how I fixed this:
I first ran bundle install from my Mac, that added 1.13.3-x86_64-darwin in my Gemfile.lock.
Before running docker-compose up, I added linux platform to my Gemfile.lock by running:
bundle lock --add-platform x86_64-linux
This is what my Gemfile.lock has now:
...
nokogiri (1.13.3-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.13.3-x86_64-linux)
racc (~> 1.4)
...
PLATFORMS
x86_64-darwin-21
x86_64-linux

Running a forked repo

I'm attempting to fork the repo and run it locally. Steps I took so far are:
Download repo
Change gemname gem version in version.rb to 1.4.0 because version is not available
Uninstall and reinstall bundler to version 1.6.1
Run bundle install
Get the error Make sure that gem install gemname -v '1.4' succeeds before bundling.
Run gem install gemname -v '1.4' and installed gem successfully
Run bundle install and I loop back to the error on step 5
I clearly have surveyor installed but yet bundler doesn't seem to recognize this. I'm a novice and very rusty on Rails.
Thanks in advance for your help!
To depend on a version of a gem in a Git repo, tell the bundler to fetch the gem from the repo.
gem 'surveyor', '~> 1.4', git: 'https://github.com/scwong93/surveyor/'
And then run bundle as normal. You should see...
Using surveyor 1.4.1.q from https://github.com/scwong93/surveyor/ (at master#e253789)
Look inside your Gemfile.lock and see that it has indeed found the repo version 1.4.1q by pulling it from the repo's master branch.
GIT
remote: https://github.com/scwong93/surveyor/
revision: e25378983fd465db701610eb076179c74db98c11
specs:
surveyor (1.4.1.q)
formtastic (~> 2.2.1)
haml (>= 4.1.0.beta.1)
mustache (~> 0.99)
rabl (~> 0.6)
rails (>= 3.2)
sass
uuidtools (~> 2.1)

I'm getting gem errors when running middleman server

When I run middleman server I get
WARN: Unresolved specs during Gem::Specification.reset:
activesupport (~> 4.2)
padrino-helpers (~> 0.13.0)
memoist (~> 0.14)
uglifier (~> 3.0)
WARN: Clearing out unresolved specs.
I tried to do gem clean as well as gem clean [gem-name] but I still get those errors.
I've read that bundler and guarding gems can help but when I run bundle exec guard I get error bundler: command not found: guard and I did previously run gem bundler install
How can this be resolved?
this means that you have more than one version of the listed gems installed on your system. Uninstall the older versions of the gem and try again.
you can try
gem uninstall [gem-name]

My nokogiri gem conflict with another version

When I run command to create rails app, i get error Unable to activate rails-dom-testing-1.0.7, because nokogiri-1.5.11 conflicts with nokogiri (~> 1.6.0) (Gem::ConflictError)
How can i uninstall old version of nokogiri? or use new version by default?
Try gem uninstall nokogiri -v '1.5.11'

Spree Commerce installation error, Bundler could not find compatible versions for gem "rails"

At the time I install the Spree site (in according with this guide: http://guides.spreecommerce.com/getting_started.html) , I get this problem:
deploy#bothunter:~/rails$ sudo -i gem install rails
Successfully installed rails-3.2.1
1 gem installed
deploy#bothunter:~/rails$ sudo -i gem install bundler
Successfully installed bundler-1.0.22 1 gem installed
deploy#bothunter:~/rails$ sudo -i gem install spree
Successfully installed spree-1.0.0 1 gem installed
deploy#bothunter:~/rails$ rails new mystore -d mysql create
create README.rdoc
create Rakefile
create config.ru
.....
run bundle install
Fetching source index for https://rubygems.org/
Using rake (0.9.2.2)
Using activemodel (3.2.1)
.....
Using rack-test (0.6.1)
Using hike (1.2.1)
Using actionpack (3.2.1)
.....
Using coffee-rails (3.2.2)
Using jquery-rails (2.0.0)
Using mysql2 (0.3.11)
Using rails (3.2.1)
Using uglifier (1.2.3)
Your bundle is complete! Use bundle show [gemname] to see where a bundled gem is installed.
deploy#bothunter:~/rails$ cd mystore
deploy#bothunter:~/rails/mystore$ spree install
Would you like to install the default gateways? (yes/no) [yes]
...
gemfile spree
gemfile spree_usa_epay
gemfile spree_skrill run
bundle install from "."
git://github.com/spree/spree_usa_epay.git (at 0cb57b4) is not checked out. Please run bundle install precompiling assets
git://github.com/spree/spree_usa_epay.git (at 0cb57b4) is not checked out. Please run bundle install
deploy#bothunter:~/rails/mystore$ bundle install
Updating git://github.com/spree/spree_usa_epay.git
Updating git://github.com/spree/spree_skrill.git
Fetching source index for sitename.com
Bundler could not find compatible versions for gem "rails":
**In Gemfile:
spree_usa_epay (>= 0) ruby depends on
rails (<= 3.1.3, >= 3.1.1) ruby
**rails (3.2.1)**
deploy#bothunter:~/rails/mystore$
But...
deploy#bothunter:~/rails/mystore$ gem --list
rails (3.2.1, **3.1.3**)
railties (3.2.1, **3.1.3**)
rake (0.9.2.2, 0.9.2)
How to solve it?
Spree 1.0 only works with Rails 3.1.3. We'll be looking at supporting Rails 3.2 in the next minor release of Spree. Until that comes out, use 3.1.3, like this:
gem install rails -v 3.1.3
I'm pretty sure the problem here is that the rails version has progressed ahead of what spree is expecting. So if you create the new rails app with the 3.1.3 version by typing in:
rails _3.1.3_ new my_app_name
then you will get past this error. However, after that, I got another error during bundle install that I have not yet solved.

Resources