Undefined local variable or method `make' when installing therubyracer on MacOS - ruby-on-rails

I've been developing on this project for about a year now, but about a month ago I ran into an issue where I had a gem installed that was incompatible with my version of ruby (using rbenv; 2.3.1). I blew up the directory, uninstalled all of my gems, uninstalled rbenv, then installed rbenv and ruby. My fellow developers haven't had any problem getting the project setup, but when I run bundle install, my install always seems to fail on therubyracer 0.12.3 with the following error:
Fetching therubyracer 0.12.3
Installing therubyracer 0.12.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/deaster/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/therubyracer-
0.12.3/ext/v8
/Users/deaster/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20191211-2125-b9wazv.rb extconf.rb
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/deaster/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-18/2.3.0-
static/therubyracer-0.12.3/mkmf.log
current directory: /Users/deaster/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/therubyracer-
0.12.3/ext/v8
make "DESTDIR=" clean
/Users/deaster/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/make-0.3.1/bin/make:4:in `<top
(required)>': undefined local variable or method `make' for main:Object (NameError)
from /Users/deaster/.rbenv/versions/2.3.1/bin/make:23:in `load'
from /Users/deaster/.rbenv/versions/2.3.1/bin/make:23:in `<main>'
current directory: /Users/deaster/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/therubyracer-
0.12.3/ext/v8
make "DESTDIR="
/Users/deaster/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/make-0.3.1/bin/make:4:in `<top
(required)>': undefined local variable or method `make' for main:Object (NameError)
from /Users/deaster/.rbenv/versions/2.3.1/bin/make:23:in `load'
from /Users/deaster/.rbenv/versions/2.3.1/bin/make:23:in `<main>'
make failed, exit code 1
Gem files will remain installed in
/Users/deaster/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/therubyracer-0.12.3 for inspection.
Results logged to /Users/deaster/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-
18/2.3.0-static/therubyracer-0.12.3/gem_make.out
An error occurred while installing therubyracer (0.12.3), and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.12.3'` succeeds before bundling.
In Gemfile:
therubyracer
I can't seem to find this same error reproduced anywhere. Prior to the install, when I run which make I get:
developer.rhapsody.com git:(master) which make
/usr/bin/make
developer.rhapsody.com git:(master) make --version
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for i386-apple-darwin11.3.0
However, after I try to run gem install therubyracer -v '0.12.3', when I run which make I get
developer.rhapsody.com git:(master) which make
/Users/deaster/.rbenv/shims/make
developer.rhapsody.com git:(master) make --version
/Users/deaster/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/make-0.3.1/bin/make:4:in `<top
(required)>': undefined local variable or method `make' for main:Object (NameError)
from /Users/deaster/.rbenv/versions/2.3.1/bin/make:23:in `load'
from /Users/deaster/.rbenv/versions/2.3.1/bin/make:23:in `<main>'
I've blown up this project and rbenv several times in order to get this working but I can't get past this step. My team members never run into this error so they're having a hard time helping me get setup. I understand that something is wrong with the make gem, but I'm not sure how to fix it.
Any thoughts?

The make gem has nothing to do with the GNU make program.
A gem that shortcuts typing out forms and tables for SQL users.
Assuming your model is named ModelName, just type
Make.form.model("ModelName").now! in your controller and it will
return an html-safe form based on your column names for creating a new
record in your view. In addition, you can type
Make.table.model("ModelName").now! to automatically generate a table.
- https://rubygems.org/gems/make
Its just a really badly named gem of questionable quality.
Whats going on here is that you ran gem install make (or it was included in the Gemfile) and now the shim generated by RBenv is shadowing GNU make on your system. What I don't understand is how the gems authors could be so clueless and not see that this would be a HUGE problem.
Running $ gem uninstall make should fix the problem. Also ensure that its not in your Gemfile.

Fortunately, I was able to get this working.
Unfortunately I'm not sure what fixed the issue. I didn't make any more changes to the project or environment between getting the bundle install errors and then finally being successful. The only thing that happened was my VSCode ran into some unrelated issue and crashed my computer. When I booted back up, bundle install was successful and I was able to run the project. I'm not sure what that's indicative of, but I'm still looking for more insight in case I run into this in the future.

Related

Bundle install errors and cannot continue, even after installing missing gems

I am working on multiple Ruby on Rails applications and running...
MacOS 10.15.7,
Ruby 2.6.5,
Rails 5.2.3,
In a project app directory I am trying to run a bundle install and get the following error:
An error occurred while installing jaro_winkler (1.5.3), and Bundler cannot continue.
Make sure that `gem install jaro_winkler -v '1.5.3' --source
'https://.../api/gems/rubygems/'` succeeds before bundling.
I proceed to install the gem from the specified source and get confirmation of install
Building native extensions. This could take a while...
Successfully installed jaro_winkler-1.5.3
Parsing documentation for jaro_winkler-1.5.3
Done installing documentation for jaro_winkler after 0 seconds
1 gem installed
after running bundle install again, I will get the original error
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/private/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3/ext/jaro_winkler
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r
./siteconf20210406-62421-10txxc5.rb extconf.rb
creating Makefile
current directory:
/private/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3/ext/jaro_winkler
make "DESTDIR=" clean
current directory:
/private/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3/ext/jaro_winkler
make "DESTDIR="
make: *** No rule to make target
`/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19/ruby/config.h',
needed by `adj_matrix.o'. Stop.
make failed, exit code 2
Gem files will remain installed in
/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3
for inspection.
Results logged to
/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/extensions/universal-darwin-19/2.6.0/jaro_winkler-1.5.3/gem_make.out
An error occurred while installing jaro_winkler (1.5.3), and Bundler cannot continue.
Make sure that `gem install jaro_winkler -v '1.5.3' --source
'https://.../api/gems/rubygems/'` succeeds before bundling.
The error message above doesn't give me any clear indication of what is happening. Additionally there is no such directory in the location where the message says "results logged to."
This seems to be happening in multiple application directories - but with different affected gems in each directory. They are all similar in that the error reads "make sure gem succeeds before bundling", then the gem install will succeed, and then the following bundle install will fail with the same original message.
Earlier today I did a clean Ruby 2.6.5 install and updated the Xcode CLI via xcode-select --install
If I run gem which jaro_winkler I get
/Users/{username}/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/jaro_winkler-1.5.3/lib/jaro_winkler.rb
Does anyone have any information on what could be causing this? I cannot do any bundle install without this happening. Please let me know if any more information is desired.
Thank you!
You mentioned that you are using ruby 2.6.5, but the gem is attempting to be installed in 2.6.0. Check that your Gemfile has the correct Ruby version in it.
When you ran gem which, it looks you are using rbenv. Make sure that you are using the correct Ruby version in there, too. Those rubies get installed in a different directory than xcode's. Sometimes there's a .rbenv file in the dir that will set the version as well.
Just some ideas. Hopefully something sticks.
Ended up being an issue with gem install location - export PATH="/usr/local/bin:$PATH" was previously added to my .bash_profile and this was effecting where gems were installed.
Somewhere in the error message /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby is mentioned - this is the "system default" Mac version of Ruby and is not the Ruby version I was intending to use with .rbenv ( 2.6.5 ) and gem installs.
Removing the export mentioned above help resolve the issue.
edit- wording

can't load pg gem even after installation

Sorry if the question is basic and forms of this has been asked. My sysadmin is out of the country so I'm stuck trying to figure this out. And none of the similar question has the exact situation (believe me I looked and have been banging my head against the wall for some time).
See below for my ruby/gem, which are all 1.9.3. Then upon running it somehow shows 1.9.1, not sure why. Anyway I've tried installing pg, the missing gem. It looked like it installed but re-running gives the same error message.
Please ask me any other information you feel is relevant.
rails#alpite:~/solr_indexer$ which ruby
/usr/local/rvm/rubies/ruby-1.9.3-p551/bin/ruby
rails#alpite:~/solr_indexer$ which gem
/usr/local/rvm/rubies/ruby-1.9.3-p551/bin/gem
rails#alpite:~/solr_indexer$ ruby indexer.rb
/usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- pg (LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/rails/solr_indexer/cfg.rb:2:in `'
from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from indexer.rb:1:in `'
rails#alpite:~/solr_indexer$ gem install pg
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/local/rvm/gems/ruby-1.9.3-p551 directory.
rails#alpite:~/solr_indexer$ sudo gem install pg
[sudo] password for rails:
Sorry, try again.
[sudo] password for rails:
Building native extensions. This could take a while...
Successfully installed pg-0.17.1
1 gem installed
Installing ri documentation for pg-0.17.1...
Installing RDoc documentation for pg-0.17.1...
rails#alpite:~/solr_indexer$ ruby indexer.rb
/usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- pg (LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/rails/solr_indexer/cfg.rb:2:in `'
from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-1.9.3-p551/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:54:in `require'
from indexer.rb:1:in `'
You're using a multi-user RVM installation to manage multiple Rubies. When using that, don't use sudo to install gems. The RVM installation page says:
Note: The Multi-User install instructions must be prefixed with the sudo command. However, once the install is complete, and the instructions to add users to the rvm group is followed, the use of either sudo or rvmsudo is no longer required. The sudo command is only to temporarily elevate privileges so the installer can complete its work. If you need to use sudo or rvmsudo after the install is complete, some part of the install directions were not properly followed. This usually is because people execute the install as root, rather than executing the installation instructions from a non-privileged user account.
I'd recommend reading that entire page as it has important information for using RVM with your environment.
The "Sudo" page is also good reading.

Rails unable to debug

I have been messing with this issue for a very long time without any success. I just want to debug the application is either RubyMine or Aptana. Whenever I try to run the the application in debug mode I get the following exception
"/home/bsikander/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:in `require': cannot load such file -- debase (LoadError)
from /home/bsikander/.rvm/rubies/ruby-2.0.0-p576/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:in `require'
from /home/bsikander/.rvm/gems/ruby-2.0.0-p576/gems/ruby-debug-ide-0.4.23.beta1/lib/ruby-debug-ide.rb:8:in `<top (required)>'
from /home/bsikander/.rvm/gems/ruby-2.0.0-p576/gems/ruby-debug-ide-0.4.23.beta1/bin/rdebug-ide:8:in `require_relative'
from /home/bsikander/.rvm/gems/ruby-2.0.0-p576/gems/ruby-debug-ide-0.4.23.beta1/bin/rdebug-ide:8:in `<top (required)>'
from /home/bsikander/.rvm/gems/ruby-2.0.0-p576/bin/rdebug-ide:23:in `load'
from /home/bsikander/.rvm/gems/ruby-2.0.0-p576/bin/rdebug-ide:23:in `<main>'"
I searched on the internet regarding this and tried to install the debase gem but I get the following expception
Building native extensions. This could take a while...
ERROR: Error installing debase:
ERROR: Failed to build gem native extension.
/home/bsikander/.rvm/rubies/ruby-2.0.0-p576/bin/ruby extconf.rb
checking for vm_core.h... no
checking for vm_core.h... no
Makefile creation failed
**************************************************************************
No source for ruby-2.0.0-p576 provided with debugger-ruby_core_source gem.
**************************************************************************
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
I also installed the gem "debugger-ruby_core_source" but still not able to install debase or debug the application. Please help me or point me to the right direction.
My Ruby version is 2.0.0.
Recently I've switched from rvm to chruby, and I've got this same issue, after looking around and reading rubymine's error messages and stuff I tried installing ruby-debug-ide instead, and somehow it worked, so yea
gem install ruby-debug-ide
would do the trick.
I had a similar experience using RubyMine and Aptana; I'd recommend checking out byebug or pry as gem-based debugging tools for ruby, which in my experience have been easy to use and easy to get running.
I'd recommend byebug a little more highly, since pry isn't as specifically designed for debugging, and byebug's next command is a godsend at times.

Replacing RVM with rbenv --mkmf error

I was looking at replacing RVM with rbenv since I am using bundle to manage my gemfiles. rbenv, I believe, is a lot lighter in managing my Ruby versions, so I uninstalled RVM and installed rbenv. I installed the bundler gem using
gem install bundler
because we need it everywhere. Then I opened a project and installed the required version Ruby using rbenv:
rbenv install 1.9.3-p194
rbenv local 1.9.3-p194
rbenv rehash
I entered ruby -v to make sure it was using the right version of Ruby, and it was, so I tried running bundle and it ran until it tried to install RedCloth and and then failed:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb --with-cflags=-w
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:1:in `<main>'
It suggested that I install RedCoth before bundling, so I installed RedCloth:
gem install RedCloth
which succeeded. I then ran ruby -v, just to make sure it's still right, then tried running bundle update and the same error occured:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb --with-cflags=-w
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:1:in `<main>'
Gem files will remain installed in /home/ruberto/.bundler/tmp/7551/gems/RedCloth-4.2.9 for inspection.
Results logged to /home/ruberto/.bundler/tmp/7551/gems/RedCloth-4.2.9/ext/redcloth_scan/gem_make.out
An error occurred while installing RedCloth (4.2.9), and Bundler cannot continue.
Make sure that `gem install RedCloth -v '4.2.9'` succeeds before bundling.
I then tried installing a different version of Ruby but had no success there either.
Does anyone have ideas?
I subsequently tried doing the same thing in my other projects and it all seems to work just fine. I have one that uses 1.8.7 and it was as easy as setting the rbenv to the right version and then running bundle. I tried almost every combination of Ruby version and yet it's not working.
I had a similar problem. It turned out that, even though I had the ~/.rbenv/shims directory at the front of my path, zsh was caching the location of bundle to /usr/local/bin/bundle.
The solution was simply running rehash at the shell (not rbenv rehash). This flushed all the cached commands, including bundle, and all went well after that.
I finally overcame the problem.
I had installed a wrong version of Ruby 1.8.7-p370. I then ran bundle and that had some gems compiling the native extensions against Ruby 1.8.7 when the bundle was for a 1.9.3 package, so even if I was to switch over to the 1.9.3 version and try running bundle again it would bomb out.
To fix this, I simply removed all the gems and then installed the right version of Ruby and then re-ran bundle.

Error installing the json gem on Windows

I am new to ruby on rails, I am trying to get my first project working with git and heroku. I am following the tutorial by Michael Hartl. I was originally trying to
git push heroku master
but I dont have a GemFile.lock, so I have been trying bundle installs and bundle updates but nothing works because I dont have the json native gem.
bundle update
this is the command that reuturned this error, its not the whole error i left out all the gems i already have
Installing json (1.7.3) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
"C:/Program Files/ruby-1.9.3/bin/ruby.exe" extconf.rb
creating Makefile
make
Makefile:160: warning: overriding commands for target `C:/Program'
Makefile:153: warning: ignoring old commands for target `C:/Program'
C:/Program Files/ruby-1.9.3/bin/ruby -e "puts 'EXPORTS', 'Init_parser'" > parser-i386
mingw32.def
/bin/sh: C:/Program: No such file or directory
make: *** [parser-i386-mingw32.def] Error 127
Gem files will remain installed in C:/Program Files/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/json-1.7.3 f
or inspection.
Results logged to C:/Program Files/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/json-1.7.3/ext/json/ext/parser/gem_make.out
An error occured while installing json (1.7.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.3'` succeeds before bundling.
If anybody knows how to fix my error so that i can move onto the next one or how i can get a working GemFile.lock, it would be appreciated.
Install json_pure instead on your development machine. This is a version of the json gem that does not require C-extensions (but is a bit slower).
On Heroku you should be able to go with the faster json directly.
If you want to build the C-extension on windows then you might want to look here:
The 'json' native gem requires installed build tools
You can create a windows-specific section in the Gemfile like so:
# Common gems
gem 'xyz'
...
# Platform specific gems
platforms :ruby do
gem 'json'
end
platforms :mswin, :mingw do
gem 'json_pure'
end
Windows isn't properly escaping the space in "C:\Program Files". I haven't used Windows in a while, but a quick search reveals a few fixes.
I had the same problem and found that in my config.yaml file, there was an installation of Ruby 1.9.2 that had a space in it. I had to uninstall that version of Ruby entirely, and remove it from the PATH in environment variables. Then, I re-installed the DevKit and it worked perfectly.

Resources