Unable to load a csv file into a rake task - ruby-on-rails-4

Even when the command prompt is inside the lib/tasks directory, it simply responds "No such file or directory" when given the command rake populate
Direcory Structure
lib/tasks
seed.rake
type.csv
Files
seed.rake :
task :populate do
require 'csv'
CSV.foreach('type.csv', headers: true) do |row|
puts line
end
end
type.csv :
"26","Accessories"
"24","Activ8"
"17","Bandages"
"29","Biohazard"
"1","BS8599-1 First Aid Kits"

The first thing that comes to mind - wrong path. There is some missunderstanding between you and the task about what is the start point of your path. So try outputing the current_path in the rake task to see where is it loading and then just navigate from there.
My best guess would be that the rake task sets the path to the rails root path, but I might be wrong there.

Related

Termux says "'Bad Interpreter: No such file or directory"

I have a problem and hope someone can help me. I am currently trying to write a script for Termux or Termux:Task. My script currently looks like this:
#!/data/data/com.termux/files/usr/bin/bash
cd /./sdcard/www/public/
wp post list sleep 5
Every time I load the script I get the following error message:
/data/data/com.termux/files/usr/bin/wp: /usr/bin/env: bad interpreter: No such file or directory.
I've been looking for a solution to my problem for hours, unfortunately without success.
I am using an extension for Termux called "WordPress CLI". When I start termux and enter the commands individually, everything works. But as soon as I write the commands into a sh script and start it doesn't work anymore. :(
Can anyone help me?
Thanks a lot
This is simple error you can fix it by replacing !/data/data/com.termux/files/usr/bin/bash. With #!/data/data/com.termux/files/usr/bin/bash
Please tell if you get error again
Try with #!/usr/bin/env bash in the shebang line.
Termux-exec allows you to execute scripts with shebangs for traditional Unix file structures. So shebangs like #!/bin/sh and #!/usr/bin/env python should be able to run without termux-fix-shebang.
From https://wiki.termux.com/wiki/Termux-exec
According to doc:
Why do I keep getting a '/bin/sh bad interpreter' error?
This error is thrown due to access script interpreter at nonexistent
location.
Termux does not have common directories like /bin, /sbin, /usr/bin at
their standard place. There is an exception for certain devices where
/bin is a symbolic link to /system/bin, but that does not make a
difference.
Interpreters should be accessed at this directory only:
/data/data/com.termux/files/usr/bin
There are three ways to fix this:
Install termux-exec by using pkg install termux-exec. It won’t affect the current session, but after a restart should work without
any setup. Not needed if your Termux is up to date. If still not
working, try the next workaround.
Use command termux-fix-shebang to fix the shebang line of specified file.
Use termux-chroot from package proot to setup a chroot environment mimicking a normal Linux file system in Termux.
termux-fix-shebang my_script.py of second method work for me, which it modify the shebang(first line of my_script.py) from #!/usr/bin/env python to #!/data/data/com.termux/files/usr/bin/env python. Since /usr/bin/ is not exist in Android, that's why it throws the error /usr/bin/env: bad interpreter: No such file or directory. The other solution is run with python my_script.py, neither of my_script.py nor ./my_script.py.
In my test, termux-exec of the first method only work if I added correct shebang in main script(child OR child of child script no need) and ran command export LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so.
And for the issue of this question, error shows /usr/bin/env in the middle with /data/data/com.termux/files/usr/bin/wp even though the shebang of script #!/data/data/com.termux/files/usr/bin/bash looks ok, it means that wp command (located at /data/data/com.termux/files/usr/bin/wp) used inside the script contains shebang #!/usr/bin/env wp and should modify it to #!/data/data/com.termux/files/usr/bin/env wp too. termux-exec of first method should fix this specific case too(already has correct shebang in main script).

Pycharm background tasks taking forever

I am new to pycharm and I am having trouble to run a simple file which is just to import pandas. I am having following issues:
Whenever, I open the project, "Scanning files to index" takes
forever.
I can see that in indexing, it is using packages/files from
Anaconda2 and that is why it takes forever for my program to run.
I have already tried to make certain folder "Excluded" as described here PyCharm 4.0.5 hangs on 'scanning files to index' background task
I have also deleted the "Caches" folder as described here Intelli J IDEA takes forever to update indices
Pycharm Layout
Pycharm indexes your python environment as well as your project folders. This is normal when first changing either of these. If it occurs more frequently:
View the end of the log that #Pavel mentioned in Help | Show Log in Explorer.
Replicate the command that is stalling the scan and fix any errors.
In my case the package scanning stalled with a vague [y/N] as shown
here. Searching the log I found the following conda.exe command:
Command line: C:\Users\<User>\anaconda3\Scripts\conda.exe list -p C:/Users/<User>/anaconda3/envs/py38 -e
Running this on the command line gave me a more detailed description of my environment error and how to fix it.

Rails: Production assets:precompile error

I am trying to deploy my app on Heroku but I don't know why the bellow error occurs.
I have gem 'rails_12factor', group: :production so I don't use config.serve_static_assets = true and config.assets.initialize_on_precompile as in the documentation explained that they are not needed in Rails 4.
When I execute these two commands respectively:
bundle exec rake assets:precompile
RAILS_ENV=production bundle exec rake assets:precompile
I get this error.
DEPRECATION WARNING: The configuration option `config.serve_static_assets` has been renamed to `config.serve_static_files` to clarify its role (it merely enables serving everything in the `public` folder and is unrelated to the asset pipeline). The `serve_static_assets` alias will be removed in Rails 5.0. Please migrate your configuration files accordingly. (called from block in tsort_each at /usr/local/lib/ruby/2.2.0/tsort.rb:226)
I, [2016-06-14T13:21:21.336814 #10455] INFO -- : Writing /home/rails/Desktop/hammasir/public/assets/font-awesome.min-1c15db9e10c99a36820b80616445a837a002b3f3969047f3375fba65f8fef2ba.css
I, [2016-06-14T13:21:21.337563 #10455] INFO -- : Writing /home/rails/Desktop/hammasir/public/assets/font-awesome.min-1c15db9e10c99a36820b80616445a837a002b3f3969047f3375fba65f8fef2ba.css.gz
I, [2016-06-14T13:21:21.341449 #10455] INFO -- : Writing /home/rails/Desktop/hammasir/public/assets/bootstrap.min-139ad6ac9cbd7b8cd15fa3f80b9b69e3ead570cb9686b3bb42b73a19ed62dcef.css
I, [2016-06-14T13:21:21.343432 #10455] INFO -- : Writing /home/rails/Desktop/hammasir/public/assets/bootstrap.min-139ad6ac9cbd7b8cd15fa3f80b9b69e3ead570cb9686b3bb42b73a19ed62dcef.css.gz
I, [2016-06-14T13:21:21.400914 #10455] INFO -- : Writing /home/rails/Desktop/hammasir/public/assets/jquery.fancybox-9eb4dcf39f4ad63c3bff3f55e2a0e5e8a32578cc4553c94633ce0ccdc08c2bea.css
I, [2016-06-14T13:21:21.401335 #10455] INFO -- : Writing /home/rails/Desktop/hammasir/public/assets/jquery.fancybox-9eb4dcf39f4ad63c3bff3f55e2a0e5e8a32578cc4553c94633ce0ccdc08c2bea.css.gz
I, [2016-06-14T13:21:21.405283 #10455] INFO -- : Writing /home/rails/Desktop/hammasir/public/assets/animate-0af100ee0144b8c4dc6de8605097b0920d4ea4aad067cc34fbaa7ab525d4e6a8.css
I, [2016-06-14T13:21:21.405707 #10455] INFO -- : Writing /home/rails/Desktop/hammasir/public/assets/animate-0af100ee0144b8c4dc6de8605097b0920d4ea4aad067cc34fbaa7ab525d4e6a8.css.gz
rake aborted!
Sass::SyntaxError: Invalid CSS after "}": expected selector or at-rule, was "}"
(sass):86
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
I debugged and checked one of the files but I couldn't find any error like forgetting to use ), } or ; . Also, I cleaned the whole content of one of them and replace it by a simple CSS rule, but still I get the error!!
This error is also happening when I try to push my app to Heroku. Please, help me to understand what is the reason and its solution??
This is the answer I found, wishing it to be useful for others, too.
To solve the DEPRECATION WARNING, update your gems as expressed by:
Asset pipeline DEPRECATION WARNING tsort.rb:226
And about the main error, you should find which file causes the error exactly. The error output and mentioned files in it are misleading and not necessarily contain syntax error.
You can work with your assets.rb file to find which file (files) contains syntax error. Comment or remove all of the referred files in assets.rb except one, redo asset precompile command in your production mode:
RAILS_ENV=production bundle exec rake assets:precompile
and repeat it for all other css files to understand which one contains the error. This time the output of this command will be helpful and refer exactly to the problem. Then, it would be easy to find the error and fix it.

python not accessible in powershell v3 when opened with Popen

Hopefully this should be simple. Python environment is running fine if I open PowerShell v3 manually. I can check version and run external scripts etc. But as soon as I open powershell.exe through subprocess.Popen from a python script from another application, python simply won't run; "The term 'Python' is not recognised as the name of a cmdlet, function, script file or operable program... etc"
I've checked my environment paths repeatedly and python is running fine on the system in general.
anyone has any idea what this could be caused by?
subprocess.Popen(["powershell.exe", '-ExecutionPolicy', 'RemoteSigned', "path to PS1_script_with python command"])
My PS1 file looks like this:
cd C:\Users\David\Geeknote\geeknote-master\geeknote
python gnsync.py --path "C:\Users\David\Desktop\C4DtoEvernote", --mask "*.nfo", --notebook "Python Logs"
function Pause{Read-Host 'You have successfully synced your C4D Annotations to Evernote using gnsync.
Please press Enter to continue...' | Out-Null}
Pause{}
It seems (for whatever reason) your $PATH is not being read or honored by the process; and thus python cannot be found.
You can either:
Set up the path with $env:Path = "C:\Python27:C:\Python27\Scripts";
Setup the path using a custom console profile (ie, a .ps1 file) and passing it with -PSConsoleFile.
The simplest option, pass the full path to the Python executable in your command file C:\Python27\python.exe gsync.py ...
I would try #3, and then see if you need the other options.
Adjust the paths as appropriate - especially if you have multiple Python interpreters installed.

Minko error building SDK

I am trying to compile the Minko framework on Windows 10 targeted at HTML. However, I'm hitting an error running the build_html5.bat script.
I've followed the instructions and completed all the steps (except for moving from the main branch to the dev branch, which is listed as optional). I cloned the source, set the new Environment Variable, ran the install_emscripten.bat file, and ran the specified commands in the emscripten command prompt.
However, when I try to run the build_html5.bat script, I get the following error:
I've looked in the MINKO_HOME directory and was able to find the jsoncpp.cpp file, but the jsoncpp.o file is not where in the directory specified in the command being called. The only file in MINKO_HOME/framework/obj/html5/release is a file named 'linker.rsp'.
I tried pulling down the dev branch into a different directory and updating the MINKO_HOME variable accordingly. I couldn't find the tool directory, but I was able to run the script scripts/solution_gmake_full.bat, after my first error trying to run build_html5_full.bat. When trying to run build_html5_full.bat, however, I get a different error:
Am I missing something here? Any help would be appreciated!
Sincerely,
Alex