Rails unable to debug - ruby-on-rails

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.

Related

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

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.

Rails install fails - cause by Nokogiri gem?

I am trying to setup a ruby on rails environment on my mac in order to start using the RubyMine IDE.
I have used homebrew, rbenv and all other required libraries in order to install ruby/rails - however when I sudo gem install rails the install fails due to :
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: /usr/local/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8.1/ext/nokogiri
/usr/local/opt/ruby/bin/ruby -r ./siteconf20161110-767-xwnfls.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.1.0
checking for iconv.h... yes
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** 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 have tried to install Nokogiri on it's own and I get the following error:
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /usr/local/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8.1/.autotest
I really hope somebody can help me as I am quite a noob to RonR and I feel like things have gotten messy directory/permission wise,
Thank you.
Let's take a quick look at a small part of the error that you have provided us.
zlib is missing; necessary for building libxml2
It's trying to tell you that you do not have zlib, so let's get it. Since you said you're using a Mac, I would install a package manager like Homebrew. Try doing brew install zlib to install this package.
Additionally, if you're starting out learning Ruby, regardless of what platform you are using, it might be helpful to use something like rbenv or rvm to manage different versions of Ruby and the gems that go along with those versions. You will run into less permissions issues (e.g. having to run gem install as a privileged user), some of which may be easy to solve, but some of which may send you down a rabbit hole for a few hours.

Broken Rails setup / pg gem

UGH... I broke my (formerly functioning) Rails setup - under OS X Yosemite. I did so using Homebrew to update my version of Git. After getting Git where I want it, running 'rails c' gives these errors:
/Users/grogers/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/pg-0.16.0/lib/pg.rb:4:in `require': dlopen(/Users/grogers/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/pg-0.16.0/lib/pg_ext.bundle, 9): Library not loaded: /usr/local/lib/libpq.5.6.dylib (LoadError)
Referenced from: /Users/grogers/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/pg-0.16.0/lib/pg_ext.bundle
Reason: image not found - /Users/grogers/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/pg-0.16.0/lib/pg_ext.bundle
Seeing the reference to pg_ext, I tried to verify pieces of my postgresql installation. If I try 'gem install pg' or try to update the gem with bundler, I get this:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/grogers/.rbenv/versions/2.0.0-p353/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
*** 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'm probably making my problem worse, but I went back and redid a 'brew install postgres' but still get the same error.
Any help appreciated. Thank you!
Did you also upgrade Postgresql via Homebrew? If not, what version of Postgres are you running, and how do you install it?
If you did upgrade your Postgres you'll need to rebuild the native bindings for the pg gem: gem uninstall pg && gem install pg.

Cannot install JSON gem in rails using windows

I am doing a bundle install and all of the gems work fine except JSON when it get to the JSON gem I receive this error.
Installing json (1.6.1) with native extensions c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:55
2:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::E
xtensionBuildError)
c:/Ruby192/bin/ruby.exe extconf.rb
checking for re.h... *** 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.
Any idea on what could be causing this error?
You are working with Windows, so the RubyInstaller Development Kit may help you:
http://rubyinstaller.org/add-ons/devkit/
The devkit installs a C-compiler (and some other stuff) to compile C-written parts.
Install it and try again to install the gem - perhaps with option --platform=ruby.
Details can be found at https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
That's because this gem using a piece of code written on C. For working properly you need c compiler installed on your machine. As a way, try to use json_pure written on pure Ruby
I'm not an expert in ROR, but the JSON installation issue which I got while installing Redmine was resolved by doing the following:
Create a make.bat at D:\LANGS\MinGW\bin
Keep this directory in the PATH
Edit the above make.bat and add a line, D:\LANGS\MinGW\msys\1.0\bin\make.exe
What I realized is, mingw32-make.exe never worked, but 'D:\LANGS\MinGW\msys\1.0\bin\make.exe' worked.
Note: My MinGW installation is under D:\LANGS\ . Please make the changes accordingly in your specific installation.
Yes, install the development kit. Also, You will need to run a few command lines to install it (not just simply download and run).
Download it, run it to extract it somewhere (permanent). Then cd to it, run ruby dk.rb init and ruby dk.rb install to bind it to ruby installations in your path.
A guide for that is here:
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

can't install sqlite gem

I don't know what I've broken but I can't create any rails apps using sqlite any more.
When I try to run gem install sqlite3 or include sqlite3 in the gemfile for a rails app I get the following.
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
/Users/mark/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for sqlite3.h... *** 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'm pretty new to ruby/rails etc so this makes very little sense to me.
I also ran a sudo gem update and ran into the same problem when it tried to update nokogiri.
Updating nokogiri
Fetching: nokogiri-1.5.0.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/mark/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for libxml/parser.h... *** 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.
Any idea/suggestions of what to try to get up and running with sqlite3 would be hugely appreciated.
Using ruby 1.9.2, OSX Lion.
Thanks, mark
The sqlite3 gem has to be compiled and link against the native sqlite3 libraries, so you'll need a C/C++ compiler and the sqlite3 development headers/libraries properly installed.
On Mac OS X, you can do this by installing the latest version of XCode. That should provide the C/C++ development tools and headers that the sqlite3 gem requires. It's a big download, but without it, you can't install the sqlite3 gem using the gem command, so make sure it's installed.
After you've installed XCode, reset your terminal and try running the "gem install sqlite3" again. It should work this time.
Try installing the sqlite3 development headers by running: port install sqlite3 +universal

Resources