question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect run folder

See original GitHub issue

Brief Issue Summary

Running application from CMake: Run without debugging and CMake: Debug uses project project workspace folder as run directory instead of the application build directory.

Expected:

  1. Execute CMake: Run without debugging
  2. The executable runs in it’s own directory (for example ${workspaceRoot}/build/gui/app.exe runned in ${workspaceRoot}/build/gui/)

This how it works in QtCreator.

Apparent Behavior:

It runs in the workspace folder. This is very unconvinient because project may use plugins that need to be taken from executable folder.

Platform and Versions

  • Operating System: Arch Linux
  • CMake Version: 3.18.1
  • VSCode Version: 1.47.3
  • CMake Tools Extension Version: 1.4.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:20 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
bobbrowcommented, Sep 18, 2020

Unfortunately, I’ll need to prepare a patch for that. In the meantime, you could go to the source folder for the extension and delete the cwd: path.dirname(executable.path) line.

It’s on line 42626 of main.js in the extension’s dist folder. image

Then reload the window and you’re good to go. Do you know where the extension installation directory is?

1reaction
tndevcommented, Sep 28, 2020

@Shatur95 @grapland0 it is not that uncommon in the field of research (But I agree that the default should be the build directory).

My project code and the data are versioned with GIT and LFS in one project folder (to keep everything consistent and reproducible), copying all the data to a build directory, especially if you have a distinct build directory for debugging and release to save compilation time, is really time and space consuming (roughly 500k files with a total size of 80GB). Furthermore, changes to the data that are written back by the application, should then be tracked in the VCS again, which is another problem if the data is copied to the build directory.

Another possibility would be to create a config file with CMake, and set there the working directory as a config value and read that when the application is started. But in any IDE I used it was not a problem to set the working directory for Debug and Release builds, so there was never a need for that and as of that the change came quite unexpected.

Using the launch.json shown by @Shatur95 with "program": "${command:cmake.launchTargetPath}" seems to work fine when the menu (or shortcuts f5 and ctrl+f5) are used, but somehow have no effect on the toolbar controls (at the bottom of the window).

Read more comments on GitHub >

github_iconTop Results From Across the Web

debug looks in wrong directory - Visual Studio Feedback
After updating, then running debug, it fails. I tracked down the problem. It is looking for the debug file in %my project directory%\bin\x64\debug\myprogram.exe ......
Read more >
Folder names or locations are incorrect in Outlook
Folder names become incorrect after you run the Outlook.exe /ResetFolderNames command to reset the default folder names.
Read more >
11 Ways to Fix "The System Cannot Find The Path Specified ...
1. Run Command Prompt as an Administrator. Windows utilities cannot access all files and folders available on your device.
Read more >
Incorrect Function Error When Trying to Run Program From a ...
Problem. Newer versions of Microsoft Windows cannot run programs that reside in a shared folder (QDLS file system).
Read more >
Fix 'The Directory Name is Invalid' Error in Windows 10
It may occur due to multiple reasons such as corrupt system files, faulty applications/software, and corrupt devices like USB, HDD, SD, or DVD, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found