How to set RubyMine's default working directory to the executing .rb program's subdirectory? - jetbrains-ide

In RubyMine, I have a project with many subfolders, each of which contains:
One or more standalone single-file executable Ruby programs (.rb files);
An input text file.
In older versions of RubyMine, when running one of the standalone executable programs (via Cmd+Shift+R on my Mac), the default folder in which RubyMine would look for the input file would be the same directory as the .rb file currently being executed -- which worked great.
The code used to read the file is something like:
data = File.readlines('input.txt')
However, after recently updating RubyMine to v2022.3.1, the behavior has changed, such that RubyMines now seems to be looking in the project's root directory for the file, instead of the same subdirectory as the .rb file currently being run. This produces the error:
in `readlines': No such file or directory # rb_sysopen - input.txt (Errno::ENOENT)
To correct this, I've been going into Run (menu) > Edit Configurations; and in the Edit Configurations dialog, in the configuration that RubyMine auto-created for the current executable file, changing the Working Directory value from the default of the project's root directory, to the subfolder of the current .rb file.
However, this above workaround is annoying, since I need to do it once each for every individual one of the many individual .rb executable files in my project.
My question: How can I configure my project and/or RubyMine itself to go back to the older behavior of defaulting a given .rb file to use its own directory as the default Working Directory, instead of the project's root directory?
(This question and/or its solution might also apply to other JetBrains IDEs such as IntelliJ, since they all seem to work similarly.)

The previous behaviour has been changed with https://youtrack.jetbrains.com/issue/RUBY-29236. So now yes, the logic is the following:
in case of no Ruby module, project's root will be used
in case of Rails, its home folder
otherwise the module's root
There is no option to change it in RubyMine but you can configure the configuration template using some variable there as Working directory.

Related

How do i formulate file path for testsettings on the Runsettings file parameter <SettingsFile>

Whats the proper way to form relative file path/ or file path for the runsettings parameter
<SettingsFile>xxxxxAutomation.testsettings</SettingsFile>
In my local environment this works but when i push it to build release agents it fails since
its looking for the file in a different directory which is my release folder
but instead its looking for this file in what appears to be in a folder directory.
This is the directory its looking at E:\Agent_work\r10\a\xxxxxxxxx.testsettings,
here is my current way i have it set
<SettingsFile>xxxxxAutomation.testsettings</SettingsFile>
here is the error message
Error: The test settings file E:\Agent_work\r10\a\xxxxxxxxxx.testsettings, specified in the MSTestAdapter settings, is not available. Either access to the file is denied or the file does not exist. Ensure that the test settings file is available and try again.
instead of
E:\Agent_work\r10\a_XXXXX CI Build\drop\XXXXX_Automation_Test\bin\Release\xxxxxxxxx.testsettings
There is no documentation that states how to formulate the file path on msdn and didn't see
anything online.
I suggest you can add a Copy Files task to copy the missing file from .../bin/release folder(Use the browse option) to default working directory:
I suggest you resolve this issue via modifying your pipeline instead of settings file, so that you can also work well locally with the unchanged runsettings file.
In addition: Clean Target Folder input should be disabled(unchecked) cause our target folder is the default working folder. Deleting all files in that folder would cause unexpected issues.

How do you add plugins to SBT? [Ubuntu]

I am following the instructions on how to add plugins to Eclipse for SBT here:
https://github.com/typesafehub/sbteclipse
Add sbteclipse to your plugin definition file (or create one if
doesn't exist). You can use either: the global file (for version 0.13
and up) at ~/.sbt/0.13/plugins/plugins.sbt the project-specific file
at PROJECT_DIR/project/plugins.sbt
However, the directory does not exist in Ubuntu linux. All I see is ~/.sbt and inside of that a directory called /boot. What should I do? Is the /0.13 directory somewhere else on my computer?
Yes, just create folder next to boot under ~/.sbt/ with the full path, as it is asked in the documentation, just do
touch ~/.sbt/0.13/plugins/plugins.sbt
to create a global file with plugins.

trouble creating an axis 2 .aar file: xml/services not found error

I am trying to create an aar file using OSX 10.7.5 (as a part of this tutorial). To generate the .aar, I navigate to the directory holding my webservice in my eclipse workspace and type
jar cvf FirstWebService.aar ./*
This is the command that Apache says to use to generate the aar in their Code Listing 9 from the apache axis 2 documentation.
The command creates an.aar -- but something is wrong with the process that I am using to create the .aar because when I go to load the .aar file into tomcat's /webapps I get an .xml/services not found error.
I am not sure what to do to fix this error. If I search my computer's file system for the services.xml file, I can find it in /path to eclipse workspace/workspace/MyFirstWebService/WebContent/WEB-INF/services/FirstWebService/META-INF
but I am not sure if this file is supposed to be rolled in to the .aar file somehow or if I can just manually plunk this file somewhere into the apache directory structure to get the thing to run.
Note: I do not think I am manually unzipping or unpacking the aar like in this question. Axis2 web service error: services.xml not found I am just running the command listed above from the apache documentation.
Here is the .aar file
note I am using all of the same versions of the software as in the tutorial -- but I am using OSX 10.7.5 where they use windows in the tutorial. Accordingly, I have changed the make-aar command for windows shown in the tutorial (jar cvf FirstWebService.aar com META-INF) into the one shown above. If I just try to run the command from the tutorial jar cvf FirstWebService.aar com META-INF I get the same xml/services not found error. It gives this output in the terminal...
com: no such file or directory
META-INF: no such file or directory
added manifest
I found the issue. When you type the command to create the aar file you have to be in the directory .../EclipseWorkspace/EclipseProjectName/WebContent/WEB-INF/services. This directory contains /META-INF/services.xml. The process that makes the .aar file must be looking in this folder.

setting syntax folder from vimrc

Is there a way to set my syntax directory in vim to be a different folder than $VIMRUNTIME/.vim/syntax? I am currently trying to use a different python syntax file from work but I cannot install it to the general directory and would instead like to install from my own user folder (in this case, it would be ~/.vim/syntax).
The ~/.vim directory should work by default, I think. Have you tried creating it and seeing if it picks up your syntax file?
Try putting your syntax file in ~/.vim/after/syntax/. I should run that syntax file after any other ones that it finds. This will also work for other folders, like ~/.vim/after/ftplugin.
Note: You may have to create the after folder if it doesn't exist.

Linux/Ubuntu directory location ~/.vim/syntax/

Where is the default location for the folder ~/.vim/syntax/ on a Linux system? I am trying to add a Python addon.
You are looking for the 'runtimepath' option. The documentation is pretty detailed (use :help runtimepath) but I'll try and summarize it here:
The runtimepath option contains a list of paths, separated by commas, where vim looks for plugins, syntax files, etc. On unix, the first path is $HOME/.vim/ (aka ~/.vim/), which means that Vim looks for syntax files in your home folder first before it looks anywhere else. Vim looks for your extra files by searching ~/.vim/plugin/*.vim or ~/.vim/syntax/*.vim, depending on what type of add-ons it is loading.
The next path in runtimepath is usually /usr/share/vim/. Vim will also search this folder for plugins etc (vim looks for /usr/share/vim/plugin/*.vim, etc). This folder is where you should put add-ons when you want them available to every user.
The last path in runtimepath is usually /usr/share/vim/vim72/, or whever Vim was installed to. This tells vim where to find and load add-ons which came bundled with that particular version of Vim.
Now, Most add-ons have a mechanism so that once they have been loaded from, say, your ~/.vim/syntax/ folder, they cannot be loaded from anywhere else. So even though syntax/python.vim comes bundled with Vim and is available in /usr/share/vim/vim72/syntax/python.vim, if an alternative version is instead loaded from ~/.vim/syntax/python.vim, then the bundled syntax is ignored. This is how you can override bundled add-ons using your ~/.vim/ folder, and you can also override them for everyone by putting addons in /usr/share/vim/. The other advantage of this setup is that you can always download the latest versions of the default bundled plugins without overriding any custom plugins you may have added.
If you were to put all your addons into /usr/share/vim/vim72/, you can no longer update to the latest bundled addons without overriding your custom addons, so you should be putting addons for yourself into ~/.vim/, or addons for all users into /usr/share/vim/, but never into /usr/share/vim/vim72/.
~ is a UNIX shortcut that means "the currently logged-in user's home folder", which is typically something like /users/<username>. You should be able to find that folder by executing
cd ~
mkdir -p .vim/syntax
cd .vim/syntax
The mkdir command creates the directory if it doesn't already exist.
If you want to add the syntax for multiple users, ire and curses is on a better track.
From the docs:
$VIMRUNTIME/syntax
On my (Ubuntu) machine, this is /usr/share/vim/vim72/syntax/.
/usr/share/vim/vim72/syntax/
I added the file in the above location and it is working for puppet scripting

Resources