Bug 142597 - "open with" dialog does not set the current working directory to the applications that it launches
Summary: "open with" dialog does not set the current working directory to the applicat...
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: general (show other bugs)
Version: Git
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-06 15:03 UTC by Nadav
Modified: 2014-07-04 21:16 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.13.3


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nadav 2007-03-06 15:03:53 UTC
Version:           3.5.6 (using KDE KDE 3.5.6)
Installed from:    Unspecified Linux
Compiler:          gcc (GCC) 4.1.2 
OS:                Linux

I try to compile directly C file of hello world which compile good from the
console.

I click on it in nautilus then "open with" and type gcc.

And It not work.

$ gcc hello.c 
[nadav@myhost C]$ ls
a.out  hello.c

I also try to do it on Latex file and it is not work.

The bug is also exist in Gnome:
http://bugzilla.gnome.org/show_bug.cgi?id=414596
Comment 1 Nadav 2007-03-20 21:26:00 UTC
I found the problem, The open dialog don't change the execute directory to the current directory.

I create a file with name g:
_______________________________________________________________________
#!/bin/bash
echo "The file is" $1
cd `dirname $1`
gcc $1
echo "After execute gcc"
exit 0 
_________________________________________________________________
The $1 contain the full path, wthout the "echo "The file is" $1", The file not compile.

The output from the gcc didnt appear in the output.

___________



How do I change the title of the bug?

It should be the open with dialog not change to the current directory when it execute files from directories.
Comment 2 Nadav 2007-03-20 21:32:12 UTC
Maybe you add option to change to the current directory like the option to open in console.
Comment 3 Nadav 2007-03-20 21:41:50 UTC
Sorry without the "cd `dirname $1`" the file not compile
Comment 4 George Kiagiadakis 2008-08-09 01:55:03 UTC
Thank you for the bug report and excuse us that it took us more than a year to reply. I'd like to clear some things out.

First,
> I click on it in nautilus then "open with" and type gcc. 
...we don't care about nautilus, this is a gnome product. However, I *assume* you wanted to tell "konqueror" instead of nautilus there.

Second, I guess you are just trying to open a *.c file with gcc. This should result in compiling the file if there are no problems. This is actually the most stupid thing you could ever do. You *should* use a console. That's because you need to see the error messages that the compiler may throw to the terminal.

Anyway, if that's what you mean, you are damn right. Opening a file with gcc in a directory other than $HOME will place the generated executable in $HOME, just because konqueror sets the working directory to be $HOME always.

I don't really know if this is intentional or not.... Anyway, can you confirm that I have guessed correctly? Thank you.
Comment 5 Nadav 2008-08-09 10:56:27 UTC
You guess correctly.

I test it now and a.out file created in the home directory.

Why does konqueror set the working directory to the home directory instead of the one he open?
Comment 6 Nadav 2011-04-14 12:39:09 UTC
three years later...

Why not to set the working directory to the current directory?

happen also in Dolphin
Comment 7 Martin Koller 2011-06-04 20:51:50 UTC
I can confirm the behaviour with 4.6.3
Comment 8 cj.wijtmans 2014-06-25 22:09:36 UTC
4 years later... i cant open binaries or scripts properly since they all execute in $HOME -.-
Comment 9 cj.wijtmans 2014-06-25 22:09:58 UTC
related:

https://bugs.kde.org/show_bug.cgi?id=271824
Comment 10 Dawit Alemayehu 2014-06-26 11:28:47 UTC
(In reply to comment #9)
> related:
> 
> https://bugs.kde.org/show_bug.cgi?id=271824

That is not related at all. That is about whether the current working directory is set up properly. This one is about the selected file(s) path being passed to the script when using "Open With". Totally different issues.
Comment 11 Dawit Alemayehu 2014-06-26 11:37:53 UTC
Th(In reply to comment #10)
> (In reply to comment #9)
> > related:
> > 
> > https://bugs.kde.org/show_bug.cgi?id=271824
> 
> That is not related at all. That is about whether the current working
> directory is set up properly. This one is about the selected file(s) path
> being passed to the script when using "Open With". Totally different issues.

Correction: I meant the other bug was about directly executing the script by clicking on it vs using "Open With..." to execute it. Two different paths and not related to one another.
Comment 12 cj.wijtmans 2014-06-26 11:46:59 UTC
(In reply to comment #11)
> Th(In reply to comment #10)
> > (In reply to comment #9)
> > > related:
> > > 
> > > https://bugs.kde.org/show_bug.cgi?id=271824
> > 
> > That is not related at all. That is about whether the current working
> > directory is set up properly. This one is about the selected file(s) path
> > being passed to the script when using "Open With". Totally different issues.
> 
> Correction: I meant the other bug was about directly executing the script by
> clicking on it vs using "Open With..." to execute it. Two different paths
> and not related to one another.

In both cases the working directory doesnt seem to be set up properly. To me it is obviously related.
Comment 13 cj.wijtmans 2014-06-26 11:53:41 UTC
Is it possible to reopen https://bugs.kde.org/show_bug.cgi?id=271824 ?
Comment 14 Dawit Alemayehu 2014-06-26 12:18:38 UTC
(In reply to comment #13)
> Is it possible to reopen https://bugs.kde.org/show_bug.cgi?id=271824 ?

No. Like I said the problem might be the same (working directory not being set), but the code path is completely different. The cause for this bug is not the same as the one for 271824. Hence my comment about those two not being related. Anyways, I already have a potential fix up for review for this bug:

https://git.reviewboard.kde.org/r/118954/
Comment 15 cj.wijtmans 2014-06-26 12:33:57 UTC
(In reply to comment #14)
> (In reply to comment #13)
> > Is it possible to reopen https://bugs.kde.org/show_bug.cgi?id=271824 ?
> 
> No. Like I said the problem might be the same (working directory not being
> set), but the code path is completely different. The cause for this bug is
> not the same as the one for 271824. Hence my comment about those two not
> being related. Anyways, I already have a potential fix up for review for
> this bug:
> 
> https://git.reviewboard.kde.org/r/118954/

Not that i am experiencing bug  https://bugs.kde.org/show_bug.cgi?id=271824 .
Comment 16 cj.wijtmans 2014-06-26 12:34:44 UTC
> Not that i am experiencing bug  https://bugs.kde.org/show_bug.cgi?id=271824 .

Note*

I am experiencing both bugs... And they are extremely annoying.
Comment 17 Dawit Alemayehu 2014-06-26 12:39:17 UTC
(In reply to comment #16)
> 
> > Not that i am experiencing bug  https://bugs.kde.org/show_bug.cgi?id=271824 .
> 
> Note*
> 
> I am experiencing both bugs... And they are extremely annoying.

I cannot reproduce bug# 271824. The steps provided to reproduce that bug work correctly for me.
Comment 18 cj.wijtmans 2014-06-26 12:50:47 UTC
When you run a binary or script in dolphin that is in a subdir of $HOME what is your working directory? For me it is always $HOME.
Comment 19 cj.wijtmans 2014-06-26 13:32:17 UTC
I think the patch you made will fix both bugs though.
Comment 20 Dawit Alemayehu 2014-07-01 11:53:10 UTC
Git commit 89d4585c087daf9bdc17c4019af8065d23eb2d85 by Dawit Alemayehu.
Committed on 28/06/2014 at 01:57.
Pushed by adawit into branch 'KDE/4.13'.

When executing commands set the working directory to be the current directory
if not speified by the service.
REVIEW: 118954
FIXED-IN: 4.13.3

M  +8    -1    kinit/klauncher.cpp
M  +5    -2    kio/kio/krun.cpp

http://commits.kde.org/kdelibs/89d4585c087daf9bdc17c4019af8065d23eb2d85
Comment 21 Dawit Alemayehu 2014-07-01 11:53:44 UTC
Git commit 0a5683cac4bc38e12eaa62966e37d8d208837662 by Dawit Alemayehu.
Committed on 01/07/2014 at 11:35.
Pushed by adawit into branch 'KDE/4.13'.

Amended fix for #142957 to only apply to a local URL.
REVIEW: 118954

M  +3    -1    kinit/klauncher.cpp
M  +4    -1    kio/kio/krun.cpp

http://commits.kde.org/kdelibs/0a5683cac4bc38e12eaa62966e37d8d208837662
Comment 22 David Faure 2014-07-04 21:16:59 UTC
Git commit e9026f008961fb654274d1da9308ee8d833300f4 by David Faure, on behalf of Dawit Alemayehu.
Committed on 04/07/2014 at 21:13.
Pushed by dfaure into branch 'master'.

When executing commands set the working directory to be the current directory

if not specified by the service.

Forward port commit 89d4585 which fixes #142597.

REVIEW: 119021

(David: s/KUrl/QUrl/ and .path() -> .toLocalFile())

M  +10   -1    src/klauncher/klauncher.cpp

http://commits.kde.org/kinit/e9026f008961fb654274d1da9308ee8d833300f4