error "instance_eval" on translation
Closed this issue · 15 comments
This is my config file:
sql_connection do
adapter "mysql2"
host "localhost"
username "user"
password "xxxxxxxxxx"
database "test"
batch_size 10000
end
mongodb_connection do
host "localhost"
database "test"
end
It's my translation file
table "config" do
column "id", :key, :as => :integer
column "CODUF", :integer
column "UF", :string
column "ESTADO", :string
column "UE", :string
column "supervisao", :string
column "data_ref", :string
column "FONE", :string
column "RAMAL", :string
column "siape_chefe", :string
column "nome_chefe", :string
end
table "rev_afc" do
column "id", :key, :as => :integer
column "data", :string
column "posto", :integer
column "placa", :string
column "litros", :float
column "valor_litro", :float
column "hodometro", :integer
column "requisitante", :string
column "siape_autorizador", :integer
column "status", :integer
end
table "rev_age" do
column "CODNR", :integer
column "NR", :string
column "DATA_REQUI", :string
column "COD_LOTAC", :integer
column "CHEFE", :integer
column "LOCAL", :integer
column "TEMPO_PREV", :string
column "DIAS_PREV", :integer
column "DATA_SAIDA", :string
column "HORA_SAIDA", :string
column "DESTINO", :string
column "SERVICO", :string
column "TRANSPORTE", :integer
column "OBSERVACAO", :string
column "SIAPE_MOTO", :string
column "USUARIO", :string
column "PLACA", :string
column "KM_INICIAL", :integer
column "KM_FINAL", :integer
column "DATA_CHEGADA", :string
column "H_DISPENSA", :string
column "H_CHEGADA", :string
column "status", :integer
column "OBS_ATENDIMENTO", :string
end
table "rev_dataref" do
column "Id", :key, :as => :integer
column "id_superv", :integer
column "data_referencia", :string
end
table "rev_local" do
column "id_local", :integer
column "descricao", :string
column "id_superv", :integer
end
table "rev_motorist" do
column "Id", :key, :as => :integer
column "SIAPE", :string
column "NOME_MOTOR", :string
column "RG", :string
column "ORGAO", :string
column "UF", :string
column "id_superv", :integer
column "N_HABILITA", :string
column "CATEGORIA", :string
column "UF_HABILITACAO", :string
column "N_REGISTRO", :string
column "D_HABILITA", :string
column "D_EXPEDICA", :string
column "D_VALIDADE", :string
column "AUTORIZA", :integer
column "D_AUTORIZA", :string
column "ATIVO", :integer
end
table "rev_posto" do
column "id", :key, :as => :integer
column "rezao_social", :string
column "endereco", :string
column "fone", :string
column "cnpj", :string
column "ativo", :integer
end
table "rev_rev" do
column "CODNR", :integer
column "DATA_REQUI", :string
column "COD_LOTAC", :integer
column "CHEFE", :integer
column "LOCAL", :integer
column "TEMPO_PREV", :string
column "DIAS_PREV", :integer
column "DATA_SAIDA", :string
column "HORA_SAIDA", :string
column "DESTINO", :string
column "SERVICO", :string
column "TRANSPORTE", :integer
column "OBSERVACAO", :binary
column "SIAPE_MOTO", :string
column "USUARIO", :string
column "PLACA", :string
column "KM_INICIAL", :integer
column "KM_FINAL", :integer
column "SIAPERESP", :integer
column "DATA_CHEGADA", :string
column "H_DISPENSA", :string
column "H_CHEGADA", :string
column "DATA_ATEND", :string
column "status", :integer
column "OBS_ATENDIMENTO", :string
end
table "rev_senhas" do
column "Id", :key, :as => :integer
column "siape", :string
column "nome", :string
column "id_superv", :integer
column "login", :string
column "senha", :string
column "level", :integer
column "autoriza_comb", :integer
column "email", :string
column "ativo", :integer
end
table "rev_superv1" do
column "id_superv", :integer
column "sigla", :string
column "unidade", :string
column "nome", :string
column "endereco", :string
column "Bairro", :string
column "municipio", :string
column "local", :integer
column "uf", :string
column "cep", :string
column "telefone", :string
column "login", :string
column "senha", :string
column "OBS", :text
column "level", :integer
column "email", :string
column "data_ref", :string
column "ativo", :integer
end
table "rev_superv2" do
column "id", :key, :as => :integer
column "id_superv", :integer
column "siape", :integer
column "nome", :string
column "cargo", :string
column "ativo", :integer
end
table "rev_veiculo" do
column "id", :key, :as => :integer
column "PLACA", :string
column "TIPO", :string
column "UF1", :string
column "LOCALIZ1", :string
column "id_superv", :integer
column "UF2", :string
column "MARCA", :string
column "MODELO", :integer
column "patrimonio", :string
column "TIPOCOOMB", :string
column "COR", :string
column "CHASSI", :string
column "RENAVAM", :string
column "HODOMETRO", :integer
column "OBS", :text
column "Ativo", :integer
column "Disp", :integer
column "data", :string
end
When a run mongify process database.config translation.rb
, I get this error:
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.0/lib/mongify/translation.rb:62:in `instance_eval': undefined local v
ariable or method `"\xFF\xFEt"' for #<Mongify::Translation:0x00000003661928 @all_tables=[]> (NameError)
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.0/lib/mongify/translation.rb:62:in `instance_eval'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.0/lib/mongify/translation.rb:62:in `parse'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.0/lib/mongify/cli/command/worker.rb:55:in `execute'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.0/lib/mongify/cli/application.rb:28:in `execute!'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.0/bin/mongify:15:in `<top (required)>'
from C:/Ruby23-x64/bin/mongify:23:in `load'
from C:/Ruby23-x64/bin/mongify:23:in `<main>'
By error message, I thought it was something in the conversion of data types. So I tried to change the types of data (date to string), delete the columns of type text, also tried to eliminate most of the tables, leaving only one. Nothing worked, always the same mistake.
What is my mistake?
I'm not sure, I haven't tested Mongify on Windows.
Can you tell me what you have installed on your system (by using gem list
)?
Sorry about the delay. This is my gem list.
activemodel (5.0.0.1, 3.2.22.5)
activerecord (5.0.0.1, 3.2.22.5)
activesupport (5.0.0.1, 3.2.22.5)
arel (7.1.4, 3.0.3)
bigdecimal (1.2.8)
bson (1.10.2)
bson_ext (1.10.2)
builder (3.0.4)
concurrent-ruby (1.0.2)
did_you_mean (1.0.0)
highline (1.7.8)
i18n (0.7.0)
io-console (0.4.5)
json (1.8.3)
minitest (5.8.3)
mongify (1.3.0)
mongo (1.10.2)
multi_json (1.12.1)
mysql2 (0.4.5 x64-mingw32)
net-telnet (0.1.1)
power_assert (0.2.6)
psych (2.0.17)
rake (10.4.2)
rdoc (4.2.1)
test-unit (3.1.5)
thread_safe (0.3.5)
tzinfo (1.2.2, 0.3.52)
I think it might be an issue with Rails 5.0.0.1 being installed, try removing it and re-running the mongify command.
I just updated Mongify removing ActiveRecord 5.0 usage. Please try updated (gem install mongify
) and let me know if you still have this issue.
I did as you suggested: I removed the activerecord and called the installation again (gem install mongify
).
This is my gem list (activerecord => 4.2.7.1):
activemodel (5.0.0.1, 4.2.7.1, 3.2.22.5)
activerecord (4.2.7.1, 3.2.22.5)
activesupport (5.0.0.1, 4.2.7.1, 3.2.22.5)
arel (7.1.4, 6.0.3, 3.0.3)
bigdecimal (1.2.8)
bson (1.12.5, 1.10.2)
bson_ext (1.12.5, 1.10.2)
builder (3.2.2, 3.0.4)
concurrent-ruby (1.0.2)
did_you_mean (1.0.0)
highline (1.7.8)
i18n (0.7.0)
io-console (0.4.5)
json (1.8.3)
minitest (5.8.3)
mongify (1.3.1, 1.3.0)
mongo (1.12.5, 1.10.2)
multi_json (1.12.1)
mysql2 (0.4.5 x64-mingw32)
net-telnet (0.1.1)
power_assert (0.2.6)
psych (2.0.17)
rake (10.4.2)
rdoc (4.2.1)
test-unit (3.1.5)
thread_safe (0.3.5)
tzinfo (1.2.2, 0.3.52)
When I ran to process, it generates the following error:
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/translation.rb:62:in `instance_eval': undefined local v
ariable or method `"\xFF\xFEt"' for #<Mongify::Translation:0x00000003f3cdb8 @all_tables=[]> (NameError)
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/translation.rb:62:in `instance_eval'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/translation.rb:62:in `parse'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/cli/command/worker.rb:59:in `execute'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/cli/application.rb:28:in `execute!'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/bin/mongify:15:in `<top (required)>'
from C:/Ruby23-x64/bin/mongify:23:in `load'
from C:/Ruby23-x64/bin/mongify:23:in `<main>'
This might have something to do with you having an invisible character in your translation file. Try copying the whole translation.rb
into a plain text editor and back into your normal editor. Just to make sure it's not that.
Also try to gem remove mongify
and select version 1.3.0
First I removed version 1.3.1 (gem uninstall mongify --version 1.3.1
), but then I followed its orientation and removed all mongify and reinstalled only version 1.3.0.
I use Notepad ++ as an editor, so I can not believe that it created some invisible character. Regardless of this, I ran mongify translation
again (to generate a new file) and did not open it in the editor, I directly executed the mongify process
, and the error persisted.
@anlek ..brother .i hope u remember that i had created an other issue related to deprecation warning and update fail ...all that was wrking... but now iam getting the issue above instance eval all of a sudden
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/translation.rb:62:in instance_eval': undefined local variable or method
as' for #Mongify::Database::Table:0x000000032d8d60 (NameError)
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/database/table.rb:70:in instance_exec' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/database/table.rb:70:in
initialize'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/translation.rb:93:in new' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/translation.rb:93:in
table'
from (eval):1:in parse' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/translation.rb:62:in
instance_eval'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/translation.rb:62:in parse' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/cli/command/worker.rb:59:in
execute'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/cli/application.rb:28:in execute!' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/bin/mongify:15:in
<top (required)>'
from C:/Ruby23-x64/bin/mongify:22:in load' from C:/Ruby23-x64/bin/mongify:22:in
@roggaioso Sorry I missed your reply. Where you able to solve the issue? Did you ever figure out what made it? If not, maybe send me the translation file?
@optimus93 Please open a new ticket with an issue as this isn't related to the original issue. Also, it seems your translation.rb file might be messed up, but I'm not quite sure. Please include the file in the new issue.
Cooo cool.. thank u.. evrything is wrking fine...
I did not find the solution, so I did not continue the tests. Follow the file for your evaluation.
translation.rb.txt
Hello,
I have same issue.
Here is the error.
C:/Bitnami/rubystack-2.3.4-4/ruby/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/translation.rb:62:in `instance_eval': undefined local variable or method `"\xFF\xFEt"' for #<Mongify::Translation:0x3e35ae8 @all_tables=[]> (NameError)
from C:/Bitnami/rubystack-2.3.4-4/ruby/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/translation.rb:62:in `instance_eval'
from C:/Bitnami/rubystack-2.3.4-4/ruby/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/translation.rb:62:in `parse'
from C:/Bitnami/rubystack-2.3.4-4/ruby/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/cli/command/worker.rb:59:in `execute'
from C:/Bitnami/rubystack-2.3.4-4/ruby/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/lib/mongify/cli/application.rb:28:in `execute!'
from C:/Bitnami/rubystack-2.3.4-4/ruby/lib/ruby/gems/2.3.0/gems/mongify-1.3.1/bin/mongify:15:in `<top (required)>'
from C:/Bitnami/rubystack-2.3.4-4/ruby/bin/mongify:22:in `load'
from C:/Bitnami/rubystack-2.3.4-4/ruby/bin/mongify:22:in `<main>'
Here is my ruby file.
table "wp_users" do
column "ID", :key, :as => :integer
column "user_login", :string
column "user_pass", :string
column "user_nicename", :string
column "user_email", :string
column "user_url", :string
column "user_registered", :string
column "user_activation_key", :string
column "user_status", :integer
column "display_name", :string
end
Same issue.
table "backups" do
column "id", :key, :as => :integer
column "user_id", :integer, :references => "users"
column "file", :string
column "created_at", :datetime
column "updated_at", :datetime
end
table "meaning_types" do
column "id", :key, :as => :integer
column "name", :string
end
table "meanings" do
column "id", :key, :as => :integer
column "real_word_type", :integer
column "meaning_type_id", :integer, :references => "meaning_types"
column "root", :string
column "deleted_at", :datetime
column "created_at", :datetime
column "updated_at", :datetime
end
table "migrations" do
column "migration", :string
column "batch", :integer
end
table "password_resets" do
column "email", :string
column "token", :string
column "created_at", :datetime
end
table "user_word_language" do
column "user_id", :integer, :references => "users"
column "word_language_id", :integer, :references => "word_languages"
end
table "users" do
column "id", :key, :as => :integer
column "name", :string
column "email", :string
column "password", :string
column "remember_token", :string
column "created_at", :datetime
column "updated_at", :datetime
end
table "word_languages" do
column "id", :key, :as => :integer
column "short_name", :string
column "name", :string
column "image", :string
end
table "words" do
column "id", :key, :as => :integer
column "language_id", :integer, :references => "languages"
column "meaning_id", :integer, :references => "meanings"
column "text", :string
column "deleted_at", :datetime
column "created_at", :datetime
column "updated_at", :datetime
column "comment", :text
end
table "wotds" do
column "id", :key, :as => :integer
column "date", :date
column "meaning_id", :integer, :references => "meanings"
end
sql_connection do
adapter "mysql2"
host "localhost"
username "root"
password "root"
database "vocab_mysql"
end
mongodb_connection do
host "localhost"
database "vocab-express-test"
end
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.2/lib/mongify/translation.rb:62:in `instance_eval': undefined local variable or method `"\xFF\xFEt"' for #<Mongify::Translation:0x000000037b2a20 @all_tables=[]> (NameError)
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.2/lib/mongify/translation.rb:62:in `instance_eval'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.2/lib/mongify/translation.rb:62:in `parse'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.2/lib/mongify/cli/command/worker.rb:59:in `execute'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.2/lib/mongify/cli/application.rb:28:in `execute!'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/mongify-1.3.2/bin/mongify:17:in `<top (required)>'
from C:/Ruby23-x64/bin/mongify:22:in `load'
from C:/Ruby23-x64/bin/mongify:22:in `<main>'
ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]
Windows 10
Found it. I used this command to generate my translation file:
mongify tr .\database.config > db.rb
Opening db.rb
in VS Code, you can see in the bottom right which encoding the file is in. It was "UTF-16 LE" for me. Clicking that and selecting "Save with encoding..." -> "UTF-8" made it work.
Thank you for this awesome tool by the way.
Thanks for sharing the solution!