Spring doesn't work. [ uninitialized constant Spring::SID::DL ]
I found out a solution.
In my case, after changing the c compiler from clang to apple-gcc42 worked perfectly.
Here are the commands I used.
$ rbenv uninstall 1.9.3-p484
$ which gcc-4.2
/usr/local/bin/gcc-4.2
$ CC=/usr/local/bin/gcc-4.2
$ rbenv install 1.9.3-p484
$ rbenv rehash
Related link: https://github.com/rails/spring/issues/274
Installing Ruby on Rails on Mac
I was able to get things running by mixing @Andrew's advice with some common sense...
I first cleaned up the mess I had made:
sudo rvm remove 1.9.2
sudo rvm remove 1.9.3
sudo rvm remove 1.9.3-p545
sudo gem uninstall spring-commands-rspec
sudo gem pristine -a
sudo port uninstall rvm
I then reinstalled rvm
sudo port install rvm
and reinstalled Ruby 1.9.3 with rails:
sudo rvm install 1.9.3
sudo gem update
sudo gem install --no-ri --no-rdoc rails
The problem as described above still occurred.
I then remembered that I had received the following message when installing Ruby (confirming Andrew's comment):
WARNING: Please be aware that you just installed a ruby that is no
longer maintained (2014-02-23), for a list of maintained rubies visit:http://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering
Please consider upgrading to ruby-2.1.1 which will have all of the
latest security patches.
So, I cleaned up again:
sudo rvm remove 1.9.3
sudo rvm remove 1.9.3-p545
sudo gem uninstall spring-commands-rspec
sudo gem pristine -a
Then, I tried installing Ruby 2.1.1 and Rails:
sudo rvm install 2.1.1
sudo gem update
sudo gem install --no-ri --no-rdoc rails
This time, I got no errors when I tried to run
rails new pong; cd pong; rails generate controller welcome index
This is not an ideal answer because I still couldn't get 1.9.3 to work, but it fits my purposes (I think). Anyone have any theories explaining why 1.9.3 doesn't work?
Thanks,
Grasswistle
Rails: NameError: uninitialized constant
Some things to try:
Restart the rails console; changes to your models will only get picked up by a rails console that is already open if you do
> reload!
(although I have found this to be unpredictable), or by restarting the console.Is your model file called "phone_number.rb" and is it in "/app/models"?
You should double-check the "--sandbox" option on your rails console command. AFAIK, this prevents changes. Try it without the switch.
rails 7 zietwerk constants not found
Thanks for the updates. The problem is this glob:
config.eager_load_paths += Dir["#{config.root}/lib/**/"]
Adding to the eager load paths, adds also to the autoload paths (I find this a bit confusing, but it is how it works). Therefore, that glob is adding, for example, lib/project_name
to the autoload paths. The key observation to understand what is happening is that when there are nested root paths, the most nested one wins as far as the files and directories below that one is concerned.
So, since lib
is in the autoload paths, anything below lib
is assumed to be defined in Object
. But, since lib/project_name
is in the autoload paths too, that subtree also represents Object
. It is the same situation like the one you have in app/models
and app/models/concerns
.
These docs explain it, but they were easy to overlook in this case because it was not obvious your configuration is affected by that point.
The solution is to add only lib
:
config.autoload_paths << "#{config.root}/lib"
config.eager_load_paths << "#{config.root}/lib"
Just like that, without wildcards. Technically, the first line is redundant given the second one, but in my view this is subtle and not obvious, I personally like to make both explicit, but as you like here. (There won't be duplicated entries, the final collection passes through uniq
.)
Since we are on it, let me also comment something extra. Maybe your application already does this, but just in case, let me say that lib
has often files and directories that are not meant to be autoloaded. For example, lib/tasks
. It is clean to be deliberate about them and tell the autoloader:
Rails.autoloaders.main.ignore("#{config.root}/lib/tasks")
Otherwise, the autoloader will believe lib/tasks
is a namespace, will define an autoload for Tasks
in Object
, will eager load (== actually define) the module if eager loading is enabled, etc. Conceptually, lib/tasks
does not have code to be autoloaded/eager loaded, and the configuration has to reflect that. Same with other similar directories.
Can't generate wicked pdf in rails 4
A few things
First, you need to put this gem 'wicked_pdf'
and gem 'wkhtmltopdf-binary'
in your Gemfile
and run bundle install
Second,
According to the docs instead of
rails g wicked pdf
You should be entering
rails g wicked_pdf
Related Topics
Return Values Were Not Extracted in Ruby
"Bad Ecpoint" Ssl Error on Fresh Rvm Ruby 1.9.3 Install on Osx Mountain Lion
How to Install Ruby System-Wide Using Rbenv
How to Deal with a Page Which Fails to Load and Continue Testing in Watir-Webdriver
Ruby Gem Cucumber Ssl Error and Gem Sources
Brew Install Coreutils Failing 10.9.5 Osx
Twitter::Error::Unauthorized in Postscontroller#Create - Invalid or Expired Token
Why Is Autoload Failing to Load Files for Gems
Ruby 1.8: Hash#Sort Not Return Hash But Array (Better Way to Do This)
Can't Access the Dockerized App Launched from the Command Line from Outside
Open Xml File with Nokogiri Update Node and Save
How to Transform the Utf8 Chars to Iso8859-1
How to Convert Character Code to What I Want
Ruby: Calculate Time Difference Between 2 Times