how to setup grunt in webstorm on windows - command-line

I am Using Webstorm (PHPStorm) on Windows 7. On the actual project we are using grunt to concatenate javascript and css and also for several other build processes.
I tried to setup the grunt command as an external run command in Webstorm. The settings i tried for that are:
Name: grunt
Parameters: none
WorkingDirectory: $ProjectFileDir$
So now when I am trying to start my external run command in Webstorm, I always get the error
> grunt
Cannot run program "grunt" (in directory "C:\Users\jawidmer\workspaces\projectname"): CreateProcess error=2, The system cannot find the file specified
When I open my command line tool and navigate to the project folder, I can start grunt without any problems.
I already searched in google and tried all kinds of different combinations of settings but non of them worked..
Do you have any ideas, what I have to change to be able to start grunt from external run commands in Webstorm?
Thanks
Jan

By your description, I assume that the same way I configured it in my WebStorm installation should work just fine for you too:
I hope it helps.
UPDATE
It seems that if you add > %TEMP%\grunt & type %TEMP%\grunt & del %TEMP%\grunt to Parameters (like shown in the updated image), the build errors will be shown.
If you need to configure a task (for example grunt watch), the Parameters field must be the following:
watch > %TEMP%\grunt & type %TEMP%\grunt & del %TEMP%\grunt
Tip taken from here

Maybe this variant will be useful for somebody:
Settings -> External Tools
With this tool I can right-click folder in project and in context menu select grunt -> build

As I had problems with the path of node and grunt in linux. I've decide to add the following in Settings->External Tools, I guess in windows can be done in the same way (PHPstorm 7, in the same dialog as the prior answers):
Name: grunt Group: Node
Program: /opt/nodes/current/bin/node (my path to node files)
Parameters: /my/directory/node_modules/grunt-cli/bin/grunt watch (my path to grunt-cli binary and the parameter to the task of grunt)
Working directory: /home/user/project/ (my path to Gruntfile.js)

Related

How To Run Robot Framework Project Developed In Eclipse Via Command Line

I have created a project using Robot Framework in Eclipse via RED. I want to know how can I run this project via Windows Command Line, so that I can create a Jenkins job to run it at a particular time ? I have tried using the steps for running Eclipse Project from command line via Debug mode, but it is not helping.
Please find the project structure below
I also tried to reach this location and run this test suit using the command
Robot Test_Suite.robot, but then I'm getting below 2 errors
1.) Importing test library 'Excel_Library' failed: ImportError: No module named Excel_Library. This file is a python file which I have written to support Excel operations and it is present at below location in the project -
2.) No Such File Or Directory - Path_To_External_Input\\External_Inputs.xls
This file contains the input which is being read before performing operations related to test suite and it is present at below location -
Do I need to add those in the command line if so how to take care of that ? This project run smoothly from eclipse but only problem is coming from command line.
It seems that you are able to run robot correctly, although I would prefer lowercase R with robot command.
1) I think you have misspelled the library name. If it's a pip package, try ExcelLibrary instead, and check that you have installed it by pip list command or equivalent.
2) Please check the path. Without additional info on how and where the file is called and where the file is located are needed.

How to set the working directory when running an executable in Eclipse CDT to be the same as the executable?

I have several build dirs for different configurations (using an external build system from the CLI), so the executable name duplicates the desired cwd:
path/to/build1/executable
path/to/build1 (desired cwd)
path/to/build2/executable
path/to/build2 (desired cwd)
Is there a more convenient way to run the executable from the directory containing it, without typing the path twice?
The most likely solution would be with a variable like ${workspace_loc} under "Arguments -> Working directory", but I could not find a suitable variable.
Tested on Eclipse 4.6.3.
If you use managed build you can get away with specifying config_name appended to workspace_loc, i.e. if you project is called "test" this should work (tested on linux)
${workspace_loc:test}/${config_name:test}
My app prints
Current working dir: /home/elaskavaia/workspace/test/Debug

How to eliminate RubyMine false "No such file to load" errors

I've recently installed RubyMine on a second machine and cloned a GitHub repository there.
My application runs exactly the same as on the first machine, but the RM code inspection result is radically different: I get dozens of "No such file to load" errors.
This even though the application runs fine both from the command line and from RM.
In dialog Run/Debug Configurations, I have specified load paths (-I. -I..) in the Ruby arguments.
Does the code inspection not honor the configuration? Or perhaps it's using a different configuration?
A bit late, but you may need to mark the directories that are load path roots in your app within the Rubymine tree - right click and do "Mark Directory As/Load Path Root".
For me the other solutions did not work. However, the problem was that RubyMine detected the wrong ruby version - while rvm for the project was ruby 2.4.1, in RubyMine it defaulted to the last version it had (2.4.2). So going to RubyMine > Preferences > Ruby SDK & Gems and changing the version for the project to the correct one solved it.
If you use the "Mark Directory As/Load Path Root" action, this will apply for IDE autocompletion only. It will not be propagated onto the interpreter (as it would be in PyCharm with Python).
You have to either keep using the -I switch, or configure $LOAD_PATH in your code, or (preferably) set up a Gem project with bundler support. You can then configure the path in a gemspec file. See https://www.jetbrains.com/help/ruby/creating-gem-project.html.
Sources:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206741945-Load-Path-not-working-at-all-
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206727915-Building-RubyGems-lib-in-load-path-
You can try changing Project Path Mappings and set relative Local Path and Remote Path to get it to work.

PyCharm - automatically set environment variables

I'm using virtualenv, virtualenvwrapper and PyCharm.
I have a postactivate script that runs an "export" command to apply the environment variables needed for each project, so when I run "workon X", the variables are ready for me.
However, when working with PyCharm I can't seem to get it to use those variables by running the postactivate file (in the "before launch" setting). I have to manually enter each environment variable in the Run/Debug configuration window.
Is there any way to automatically set environment variables within PyCharm? Or do I have to do this manually for every new project and variable change?
I was looking for a way to do this today and stumbled across another variation of the same question (linked below) and left my solution there although it seems to be useful for this question as well. They're handling loading the environment variables in the code itself.
Given that this is mainly a problem while in development, I prefer this approach:
Open a terminal
Assuming virtualenvwrapper is being used, activate the virtualenv of the project which will cause the hooks to run and set the environment variables (assuming you're setting them in, say, the postactivate hook)
Launch PyCharm from this command line.
Pycharm will then have access to the environment variables. Likely because of something having to do with the PyCharm process being a child of the shell.
https://stackoverflow.com/a/30374246/4924748
I have same problem.
Trying to maintain environment variables through UI is a tedious job.
It seems pycharm only load env variables through bash_profile once when it startup.
After that, any export or trying to run a before job to change bash_profile is useless
wondering when will pycharm team improve this
In my case, my workaround for remote interpreter works better than local,
since I can modify /etc/environment and reboot the vm
for local interpreter, the best solution I can do are these:
1. Create a template Run/Debug config template and clone it
If your env variables are stable, this is a simple solution for creating diff config with same env variables without re-typing them.
create the template config, enter the env variables you need.
clone them
see picture
2. Change your script
Maybe add some code by using os.environ[] = value at your main script
but I don't want to do this, it change my product code and might be accidentally committed
Hope someone could give better answer, I've been spent too much time on this issue...
Another hack solution, but a straightforward one that, for my purposes, suffices. Note that while this is particular to Ubuntu (and presumably Mint) linux, there might be something of use for Mac as well.
What I do is add a line to the launch script (pycharm.sh) that sources the needed environment variables (in my case I was running into problems w/ cx_Oracle in Pycharm that weren't otherwise affecting scripts run at command line). If you keep environment variables in a file called, for example, .env_local that's in your home directory, you can add the following line to pycharm.sh:
. $HOME/.env_local
Two important things to note here with respect to why I specifically use '.' (rather than 'source') and why I use '$HOME' rather than '~', which in bash are effectively interchangeable. 1) I noticed that pycharm.sh uses the #!/bin/sh, and I realized that in Ubuntu, sh now points to dash (rather than bash). 2) dash, as it turns out, doesn't have the source "builtin", nor will ~ resolve to your home dir.
I also realize that every time I upgrade PyCharm, I'll have to modify the pycharm.sh file, so this isn't ideal. Still beats having to manage the run configurations! Hope it helps.
OK, I found better workaround!
1.install fabric in your virtualenv
go to terminal and
1. workon your virtualenv name
2. pip install fabric
2. add fabric.py
add a python file and named it "fabric.py" under your project root, past the code below,and change the path variables to your own
from fabric.api import *
import os
path_to_your_export_script = '/Users/freddyTan/workspace/test.sh'
# here is where you put your virtualenvwrapper environment export script
# could be .bash_profile or .bashrc depend on how you setup your vertualenvwrapper
path_to_your_bash_file = '/Users/freddyTan/.bash_profile'
def run_python(py_path, virtualenv_path):
# get virtualenv folder, parent of bin
virtualenv_path = os.path.dirname(virtualenv_path)
# get virtualenv name
virtualenv_name = os.path.basename(virtualenv_path)
with hide('running'), settings(warn_only=True):
with prefix('source %s' % path_to_your_export_script):
with prefix('source %s' % path_to_your_bash_file):
with prefix('workon %s' % virtualenv_name):
local('python %s' % py_path)
3. add a external tool
go to
preference-> External tools -> click add button
and fill in following info
Name: whatever
Group: whatever
Program: "path to your virtualenv, should be under '$HOME/.virtualenvs' by default"/bin/fab
Parameter: run_python:py_path=$FilePath$,virtualenv_path=$PyInterpreterDirectory$
Working directory: $ProjectFileDir$
screenshot
wolla, run it
go to your main.py, right click, find the external name (ex. "whatever"), and click it
you could also add shortcut for this external tool
screenshot
drawbacks
this only work on python 2.x, because fabric don't support python 3

how to run coffeescript with web storm

I'm having trouble running a coffeescript configuration with webstorm. If I enable the coffeescript plugin in the run configuration I get the following error
/usr/bin/coffee app.coffee
env: node: No such file or directory
I tried the solution in the support forums of adding my path variable to the environment variables but still no fix.
Because, the executable file is not found yet.
Goto Terminal and type: echo NODE_PATH or echo $NODE_PATH to see where is the file.
On windows, C:\Users[YOUR_USER_NAME]\AppData\Roaming\npm\node_modules\coffee-script\bin\coffee
So, use Spotlight search tool to have a look at /usr/local/npm ..... or somewhere else.
Try to pass absolute path to your app.js. Webstorm sometimes mess with relative paths.
On Windows, I had a lot of trouble with this, you must find your "coffee" file. BTW, this could help you too.
After you installed Node.js and installed the CoffeScript plugin:
Download the last version (or source) from CoffeeScript.org
Unzip it wherever you want. In my case I unzipped the jashkenas-coffeescript-1.10.0-0-gf26d33d.tar.gz on D:\tools\
Check 'Run with CoffeeScript plugin'
Target the coffee executable on menu 'Run > Edit Configurations...':