I'm running Rails 5.1.7 and was using Ruby 2.4.3. I don't have the option to upgrade my Rails version presently, and due to Rails 5.1.x compatibility, I'm forced to go onto Ruby 2.5.x at max.
Due to a Ruby bug causing segfaults in 2.4.3, I have to upgrade Ruby to a different version.
Ruby 2.5.8 has an issue that stack traces no longer appear in Rails Console or when running Puma in development for me. Stack traces do appear when running irb, just not rails c.
I've confirmed that changing back to Ruby 2.4.3 with no other changes to the code or gems fixes the issue and stack traces appear again.
Any ideas as to how I can get stack traces in the later Ruby version?
Ruby 2.4.3 - Rails Console
$ rails c
Loading development environment (Rails 5.1.7)
2.4.3 :001 > raise 'test'
RuntimeError: test
from (irb):1
2.4.3 :002 >
Ruby 2.5.8 - Rails Console
$ rails c
Loading development environment (Rails 5.1.7)
2.5.8 :001 > raise 'test'
Traceback (most recent call last):
RuntimeError (test)
2.5.8 :002 >
This is just the minimum steps required for reproduction, the same issue occurs when an exception is thrown in the code.
For comparison, this is what shows up for irb
Ruby 2.4.3 - irb
$ irb
2.4.3 :001 > raise 'test'
RuntimeError: test
from (irb):1
from /home/user/.rvm/rubies/ruby-2.4.3/bin/irb:11:in `<main>'
2.4.3 :002 >
Ruby 2.5.8 - irb
$ irb
2.5.8 :001 > raise 'test'
Traceback (most recent call last):
2: from /home/user/.rvm/rubies/ruby-2.5.8/bin/irb:11:in `<main>'
1: from (irb):1
RuntimeError (test)
2.5.8 :002 >
This was due to gems I had in my bundle that were meant for giving a pretty exception output in development.
gem 'better_errors'
gem 'binding_of_caller'
Once those were updated to newer versions, stack traces were once again available in the rails console.
$ rails c
Loading development environment (Rails 5.1.7)
2.5.8 :001 > raise 'test'
Traceback (most recent call last):
1: from (irb):1
RuntimeError (test)
2.5.8 :002 >
Related
I read some of the related topics and tried to implement those solutions to my situation but still I get the following error after this command :
(project2_env) Efe-MacBook-Air:MySQL-python-1.2.4b4 efe$ python setup.py build
The Error message is :
Extracting in /var/folders/rv/vbf7xqh1601_xjkrn85w7hp00000gn/T/tmpptpsggg7
Traceback (most recent call last):
File "/Users/efe/virtualenvs/downloads/MySQL-python-1.2.4b4/distribute_setup.py", line 143, in use_setuptools
raise ImportError
ImportError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "setup.py", line 7, in <module>
use_setuptools()
File "/Users/efe/virtualenvs/downloads/MySQL-python-1.2.4b4/distribute_setup.py", line 145, in use_setuptools
return _do_download(version, download_base, to_dir, download_delay)
File "/Users/efe/virtualenvs/downloads/MySQL-python-1.2.4b4/distribute_setup.py", line 125, in _do_download
_build_egg(egg, tarball, to_dir)
File "/Users/efe/virtualenvs/downloads/MySQL-python-1.2.4b4/distribute_setup.py", line 99, in _build_egg
_extractall(tar)
File "/Users/efe/virtualenvs/downloads/MySQL-python-1.2.4b4/distribute_setup.py", line 486, in _extractall
self.chown(tarinfo, dirpath)
TypeError: chown() missing 1 required positional argument: 'numeric_owner'
Edit: I reinstalled homebrew, then I run this following command. That is successfully installed.
brew install mysql
However, I cannot still import MySQLdb in python.
As it is more complicated than the previous answer, i won't told you about the custom installation of python mysql.
Found this, the Jude's way :
Install mysql via homebrew, then you can install mysql python via pip.
xcode-select --install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
//don't know how to install mysql via homebrew, but it should be done here
pip install MySQL-python
https://stackoverflow.com/a/25356073/6660122
Taken from the Python2 doc, still relevant in 3.5 :
"Alternate installation: the user scheme
This scheme is designed to be the most convenient solution for users that don’t have write permission to the global site-packages directory or don’t want to install into it. It is enabled with a simple option: "
python setup.py install --user
Could help in your case.
Notice there are different scheme to use : --home, or --prefix and --exec-prefix, or --install-base and --install-platbase
Finally I found a solution for myself and by myself. I gave up using directly MySQLdb library and instead of that, I installed PyMySQL. By the way I had already installed MySQL Workbench before, so mysql server was already running.
Here is what I do step by step. I hope someone can get benefit from it.
1) Create a virtual environment:
virtualenv virt1
2) Make your virtual environment activated:
source virt1/bin/activate
3) Now, you are in your virtual environment. Install PyMySQL:
pip install PyMySQL
4) Now, try whether your MySQL connection is OK or not with a simple py executable:
#!/usr/bin/python
import pymysql.cursors
# Connect to the database
connection = pymysql.connect(host='localhost',
user='YourDBuserName',
password='YourDBpassword',
db='YourDBname',
charset='utf8',
cursorclass=pymysql.cursors.DictCursor)
try:
with connection.cursor() as cursor:
# Read a single record
sql = "SELECT `id`, `name` FROM `YourTableName` WHERE `id`=%s"
cursor.execute(sql, (1,))
result = cursor.fetchone()
print(result)
finally:
connection.close()
5) You should see that your first row from the table appears on the screen.
Note: The part "import pymysql.cursors" could be tricky. First, I wrote as "import PyMySQL.cursors" and that didn't work!
Not able to start rails5 with jruby, getting the following error.
gavinyap#gavin-ubuntu ~/Development/rails5app rails s
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from require at bin/rails:4)
Bundler::GemRequireError: There was an error while trying to load the gem 'activerecord-jdbcmysql-adapter'.
Gem Load Error is: uninitialized constant ActiveRecord::ConnectionAdapters::Column::Format
Backtrace for gem load error is:
/home/gavinyap/.rvm/gems/jruby-9.1.2.0/gems/activerecord-jdbc-adapter-1.3.20/lib/arjdbc/jdbc/type_cast.rb:13:in `<module:TypeCast>'
/home/gavinyap/.rvm/gems/jruby-9.1.2.0/gems/activerecord-jdbc-adapter-1.3.20/lib/arjdbc/jdbc/type_cast.rb:7:in `<module:Jdbc>'
/home/gavinyap/.rvm/gems/jruby-9.1.2.0/gems/activerecord-jdbc-adapter-1.3.20/lib/arjdbc/jdbc/type_cast.rb:4:in `< module:ConnectionAdapters>'
/home/gavinyap/.rvm/gems/jruby-9.1.2.0/gems/activerecord-jdbc-adapter-1.3.20/lib/arjdbc/jdbc/type_cast.rb:3:in `<top>'
/home/gavinyap/.rvm/gems/jruby-9.1.2.0/gems/activerecord-jdbc-adapter-1.3.20/lib/arjdbc/jdbc/column.rb:1:in `singleton cla
Versions of Jruby and Rails
jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f
OpenJDK 64-Bit Server
VM 25.91-b14 on 1.8.0_91-8u91-b14-0ubuntu4~16.04.1-b14 +jit [linux-x86_64]
Rails 5.0.0
The ActiveRecord JDBC gem has not been updated for Rails 5. Checking the project in GitHub shows some development activity early this year but there is no indication when a new gem will be released for Rails 5.
add gem 'activerecord-jdbcmysql-adapter', '~> 5.0.pre1' to your gemfile
It looks that jruby-1.7.16 does not work correctly on SunOS 5.10. At least it looks like its impossible to install additional gems.
When I try to run jgem I get the following error:
NoMethodError: undefined method `name' for nil:NilClass
_resort! at /export/home/my_user/jruby-1.7.16/lib/ruby/shared/rubygems/specification.rb:717
sort! at org/jruby/RubyArray.java:3358
_resort! at /export/home/my_user/jruby-1.7.16/lib/ruby/shared/rubygems/specification.rb:716
_all at /export/home/my_user/jruby-1.7.16/lib/ruby/shared/rubygems/specification.rb:665
each at /export/home/my_user/jruby-1.7.16/lib/ruby/shared/rubygems/specification.rb:855
reverse_each at org/jruby/RubyEnumerable.java:1072
latest_specs at /export/home/my_user/jruby-1.7.16/lib/ruby/shared/rubygems/specification.rb:971
find_latest_files at /export/home/my_user/jruby-1.7.16/lib/ruby/shared/rubygems.rb:490
load_plugins at /export/home/my_user/jruby-1.7.16/lib/ruby/shared/rubygems.rb:1006
(root) at /export/home/my_user/jruby-1.7.16/lib/ruby/shared/rubygems/gem_runner.rb:81
require at org/jruby/RubyKernel.java:1065
(root) at /export/home/my_user/jruby-1.7.16/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:1
(root) at ./jgem:9
I tried to use the same distribution on Ubuntu LTS 12.04.4 and it works correctly, gems could be installed.
I installed required gems in Ubuntu, packed jruby and moved to SunOS machine and it didn't help.
Is SunOS 5.1 fully supported by jruby? jruby and irb seem to run fine, but jgem is critical for me.
=====
EDIT:
These are gems that I found in jruby install
ls
axiom-types-0.1.1 equalizer-0.0.9 rake-10.1.0 ruby-maven-libs-3.1.1
coercible-1.0.0 ice_nine-0.11.0 rdoc-4.0.1 thread_safe-0.3.4-java
descendants_tracker-0.0.4 maven-tools-1.0.5 ruby-maven-3.1.1.0.8 virtus-1.0.3
And I added puts in front of the line you mentioned and for a.name and b.name, it looks that error happened when after virtus was compared to thread_safe:
a = virtus
b= thread_safe
1
NoMethodError: undefined method `name' for nil:NilClass
seems that some of the gem specification does not have a name (which seems weird) :
def self._resort!(specs) # :nodoc:
specs.sort! { |a, b|
names = a.name <=> b.name # line 717
next names if names.nonzero?
b.version <=> a.version
}
end
I would try putting a puts before names = a.name <=> b.name to find out what's going on ...
if it's a clean JRuby install than definitely worth an issue report, but still worth looking deeper since the core team might be low on SunOS machines :)
I am getting the following error when I try to install django CMS with MySQL using virutalenv:
RuntimeError: maximum recursion depth exceeded
/Users/ethan/Sites/env/build/mysql-python/distribute-0.6.28-py2.7.egg
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/Users/ethan/Sites/env/build/mysql-python/setup.py", line 7, in <module>
use_setuptools()
File "distribute_setup.py", line 145, in use_setuptools
return _do_download(version, download_base, to_dir, download_delay)
File "distribute_setup.py", line 125, in _do_download
_build_egg(egg, tarball, to_dir)
File "distribute_setup.py", line 116, in _build_egg
raise IOError('Could not build the egg.')
IOError: Could not build the egg.
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /Users/ethan/Sites/env/build/mysql-python
The command I am using for the install is the following:
env/bin/pip install --download-cache=~/.pip-cache -r reqs.txt
And the reqs.txt file looks like this:
django-cms==2.4.1
Django==1.5.1
django-classy-tags==0.4
South==0.8.1
html5lib==1.0b1
django-mptt==0.5.2
django-sekizai==0.7
six==1.3.0
Pillow==2.0.0
django-filer==0.9.4
cmsplugin-filer==0.9.5
django-reversion==1.7
mysql-python==1.2.4
I'm a novice to django (just going through the tutorial) and I cannot find anything in a search that seems to resolve this issue. Anyone have any ideas?
Change your requirement to mysql-python==1.2.5, I had the same problem on a CentOS 6.3 server.
mysql-python v. 1.2.4 has a hard dependency on distribute version 0.6.28. It might not be picking the right version of distribute.
Run this after the virtual env is activated:
easy_install distribute==0.6.28
and you should be good to proceed with
env/bin/pip install --download-cache=~/.pip-cache -r reqs.txt
change requirement to mysql-python==1.2.5 also worked for me on OS X mavericks with pip install
I try to run the project together with omniauth (devise + omniauth) and mysql.
For example Twitter authorization gives an error:
/Users/n3mfis/.rvm/rubies/ruby-head/lib/ruby/1.9.1/net/http.rb:784:
[BUG] Segmentation fault ruby 1.9.3dev
(2011-05-18 trunk 31628)
[x86_64-darwin10.7.0]
-- Control frame information ----------------------------------------------- c:0054 p:---- s:0330 b:0330 l:000329
d:000329 CFUNC :connect c:0053 p:0011
s:0327 b:0327 l:000a80 d:000326 BLOCK
/Users/n3mfis/.rvm/rubies/ruby-head/lib/ruby/1.9.1/net/http.rb:784
c:0052 p:0111 s:0325 b:0325 l:0024a0
d:0024a0 METHOD
/Users/n3mfis/.rvm/rubies/ruby-head/lib/ruby/1.9.1/timeout.rb:60
c:0051 p:0026 s:0313 b:0313 l:000312
d:000312 METHOD
/Users/n3mfis/.rvm/rubies/ruby-head/lib/ruby/1.9.1/timeout.rb:91
....
1069
/Users/n3mfis/.rvm/gems/ruby-head/bundler/gems/rails-505defc27ead/activerecord/lib/active_record/relation/predicate_builder.rb
1070
/Users/n3mfis/.rvm/gems/ruby-head/bundler/gems/rails-505defc27ead/activerecord/lib/active_record/associations/collection_proxy.rb
1071
/Users/n3mfis/.rvm/gems/ruby-head/gems/multi_json-1.0.2/lib/multi_json/engines/json_gem.rb 1072
/Users/n3mfis/.rvm/rubies/ruby-head/lib/ruby/1.9.1/x86_64-darwin10.7.0/enc/trans/utf_16_32.bundle
[NOTE] You may have encountered a bug
in the Ruby interpreter or extension
libraries. Bug reports are welcome.
For details:
http://www.ruby-lang.org/bugreport.html
Abort trap
If I change mysql to sqlite, then everything works fine...
For mysql and sqlite other features of the site work fine without any errors (scaffold)
I tried
ruby ruby-1.9.2-p180 and last version ruby 1.9.3dev
rails 3.0.7 and rails 3.1.0beta1
Try to add this option:
export RUBYOPT='-r openssl'