ruby encoding error on windows - ruby-on-rails

Wondering if anyone has ever come across the error
Caught Encoding::CompatibilityError at '{"command_id":"cc8bf': incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string) (JSON::ParserError)
I get this the following is called
expect(page.element.text.to_s.force_encoding("UTF-8").match msg).to be_true
As you can see, I have added "to_s.force_encoding("UTF-8")" but i still get the error.
My version of ruby is 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
Running on a mac and the tests pass with no errors.

Related

Setting breakpoints in VS code using Rails

Running into ruby version clash when trying to start the rails debugger inside of VS Code. Sorry if this is a stupid question.. I'm normally a Js guy, very new to Rails
Getting this error :
rake (>= 0.8.1)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
Uncaught exception: Your Ruby version is 2.3.7, but your Gemfile specified 2.3.1
/Library/Ruby/Gems/2.3.0/gems/bundler-1.17.3/lib/bundler/definition.rb:495:in `validate_ruby!'
/Library/Ruby/Gems/2.3.0/gems/bundler-1.17.3/lib/bundler/definition.rb:470:in `validate_runtime!'
.
.
.
When I type ruby --version in my console, I get ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin17]
Had this same issue.
Restarting the computer worked for me.
The vscode debugger console environment doesn't seem to update until a complete computer restart happens. Might be a bug or intentional.

Getting syntax error, unexpected ':', expecting '=' in Ruby

I am very new to Ruby and trying to run a script ,When I am trying to run a Ruby script like below, I am getting
> ruby test.rb
test.rb:53: syntax error, unexpected ':', expecting ')'
All::Config.new_global_config(domain: domain, realm: realm)
^
test.rb:53: syntax error, unexpected ':', expecting '='
All::Config.new_global_config(domain: domain, realm: realm)
When I see ruby version, it says:
> ruby -version
ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux]
-e:1: undefined local variable or method `rsion' for main:Object (NameError)
Any pointers? Is it because of the version? 1.8.x instead of 1.9 or more?
The {key: 'value'} syntax was added in ruby v1.9. To do this in v1.8, you need to use the {:key => 'value'} syntax (which is still valid in modern ruby, too).
1.8 and 1.9 are both very old versions!!! Neither has been supported for a long time. (1.8 was retired in 2013; 1.9 in 2015.)
The latest version, at the time of writing this, is 2.4.1. Use this if possible.
The oldest supported version of ruby is 2.2.7.

rspec test failures with present to non-English symbols

I'm comparing multiple files containing russian characters, and that's a result of getting. I replaced the symbols and the tests were properly
My environments: Rails 5.0.0.1 and ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
Files use utf-8 encoding.
Failure/Error: Feror::AppGenerator.start args, { destination_root: spec_path }
Encoding::CompatibilityError:
incompatible character encodings: ASCII-8BIT and UTF-8

cannot load such file -- Kconv

I'm wondering why i got this error on particular situation.
One of my controller class has
require 'Kconv'
on top.
And after running app by "$ rails s", i got this error (cannot load such file -- Kconv) in only my centos5.10. My mac has no problem with the code and can work correctly.
Specs
My mac
Rails 4.2.0
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12.0]
gem 2.2.2
Yosemite 10.10.2
centos5.10
Rails 4.2.0
ruby 2.1.2p95 (2014-05-08 revision 45877) [i686-linux]
gem 2.4.8
CentOS release 5.10 (Final)
And one of tutorial site mentioned about need to install 'Kconv' by gem.
But both of my pc has error with it.
ERROR: Could not find a valid gem 'kconv' (>= 0) in any repository
ERROR: Possible alternatives: bconv, conv, iconv, sconv
My question is why this error happens even if these specs are almost same. Another tutorial site said this lib is included into general package. If so, if i use same ruby version, i don't get this error, do i?
The name of the file is kconv.rb, not Kconv.rb. On your Mac, you are presumably using a case-insensitive file system such as FAT, NTFS or HFS, whereas on your CentOS box, you are using a case-sensitive file system such as ext4, btrfs or ZFS.
So, it should be
require 'kconv'
and the fact that
require 'Kconv'
works on a case-insensitive file system is just pure dumb luck.

output_safety.rb:34 warning: regexp match /.../n against to UTF-8 string

When starting up my WEBrick server, I get next warning when calling the home page:
c:/Program Files/jruby-1.6.7/lib/ruby/gems/1.8/gems/activesupport-
3.2.2.rc1/lib/active_support/core_ext/string/output_safety.rb:34
warning: regexp match /.../n against to UTF-8 string
Can someone tell me why I'm getting this warning?
+
I'm running JRuby in 1.9 mode, but here I'm getting an error from a gem in 1.8 folder. Why is that? Shouldn't the gems from the 1.9 folder be used?
this issue is discussed here github.com/rails/rails/issues/3927

Resources