Bug 452766 - Cannot open projects with -p or --project command line option or any other way on command line
Summary: Cannot open projects with -p or --project command line option or any other wa...
Status: RESOLVED NOT A BUG
Alias: None
Product: kdevelop
Classification: Applications
Component: general (other bugs)
Version First Reported In: 5.14.240501
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-19 12:38 UTC by Evren
Modified: 2024-06-18 09:34 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
workaround script that can be used (1.01 KB, application/gzip)
2024-06-18 09:32 UTC, Evren
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Evren 2022-04-19 12:38:51 UTC
STEPS TO REPRODUCE
1. On the command line, i have a file named test.kdev4 in the current folder.
2. Execute one of the following:
kdevelop -p test.kdev4
kdevelop -n -p test.kdev4
kdevelop -s default -p test.kdev4
kdevelop --project test.kdev4
kdevelop --project=test.kdev4
kdevelop -p /home/user/projects/test/test.kdev4
kdevelop --project /home/user/projects/test/test.kdev4
kdevelop -p "/home/user/projects/test/test.kdev4"
kdevelop --project "/home/user/projects/test/test.kdev4"

OBSERVED RESULT
An empty KDevelop environment opens, project doesn't load, no errors nor messages appear, just nothing.

EXPECTED RESULT
Project should be loaded on the projects list side bar

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 5.15.28-1-MANJARO (64-bit)
KDE Plasma Version: 5.24.3
KDE Frameworks Version: 5.91.0
Qt Version: 5.15.3

ADDITIONAL INFORMATION
If i don't put -p option and just project filename, kdevelop opens kdev4 file as a text file and show it in text editor, not as a project.
I am able to open projects from inside kdevelop open project menu just fine, but i need to open it on command line.
Comment 1 Igor Kushnir 2022-05-03 06:40:12 UTC
Take a look at https://invent.kde.org/kdevelop/kdevelop/-/blob/3427bd11ff34b18d3efdec3b4f23c65c0316a6e0/app/main.cpp#L720. KDevelop looks for a session that contains the project specified on the command line. If such a session exists, it is opened. Otherwise, the last used session is opened. 

You can debug this with:
QT_LOGGING_RULES='kdevelop.app.debug=true' kdevelop -p '/path/to/project'

Note that the project URL must match the one stored in the session verbatim, because unfortunately KDevelop does not seamlessly resolve symlinks.

You could implement creating and opening a new session with the project passed on the command line if there is no suitable existing session.
Comment 2 Evren 2022-05-30 16:30:12 UTC
Seems like an unexpected behaviour from a software. I have never seen such behavior in any other kde or non kde software before.

I think i need this in daily life and this bug reduces productivity.
Comment 3 Igor Kushnir 2022-05-30 17:15:57 UTC
> I think i need this in daily life and this bug reduces productivity.
Fortunately KDevelop is free software. You can implement the feature to boost productivity.
Comment 4 Igor Kushnir 2023-09-20 08:53:24 UTC
KDevelop accepts positional arguments on the command line. From the output of `kdevelop --help`:
> Arguments:
>  files                             Files to load, or directories to load as projects
So you can load a project into the last used session by passing its directory to KDevelop on the command line. For the current directory:
    kdevelop .
Comment 5 Evren 2024-06-18 09:32:48 UTC
Created attachment 170592 [details]
workaround script that can be used

This is a workaround bash script to be used if you want to open kdevelop projects directly by double clicking on the project files, it will search a session with the project and if it doesn't find it, creates a session with the project then opens the project in this new session. I wish i could implement this in kdevelop source code itself, but i just did a quick workaround instead of a full work.