bugGNU Octave - Bugs: bug #44720, edit.m: Fails to open protected...

 
 

bug #44720: edit.m: Fails to open protected file if ~/octave does not exist

Submitter:  Julien Bect <jbect>
Submitted:  Sat 04 Apr 2015 04:30:00 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Duplicate Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.0.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 02 Jun 2015 04:42:57 PM UTC, comment #11: 

Retagging release from 4.0.0-rc2 to 4.0.0.

John W. Eaton <jwe>
Group administrator
Tue 07 Apr 2015 04:26:05 PM UTC, comment #10: 

Since this bug is marked as duplicate, shouldn't it be closed ?

Julien Bect <jbect>
Sat 04 Apr 2015 06:43:35 PM UTC, comment #9: 

I meant : It can be marked as duplicate, of course...

Julien Bect <jbect>
Sat 04 Apr 2015 06:38:02 PM UTC, comment #8: 

Sure, this is obviously a duplicate of bug #41278, sorry about that. I can be marked as duplicate.

(In my defense: bug #41278 doesn't show up if I search for "cannot create regular file" in all bug reports...)

Julien Bect <jbect>
Sat 04 Apr 2015 06:21:09 PM UTC, comment #7: 

@Rik: make sure you don't have write permissions on hadamard.m, and also make sure that you don't have a ~/octave directory.


$ chmod a-w /opt/gnu/octave/share/octave/4.0.0-rc2/m/special-matrix/hadamard.m
$ rm -rf /tmp/homedir
$ mkdir /tmp/homedir
$ HOME=/tmp/homedir octave -qf --no-gui-libs
octave:1> edit mode sync
octave:2> edit hadamard
cp: cannot create regular file ‘/tmp/homedir/octave/hadamard.m’: No such file or directory
## and vim is started with an empty buffer ~/octave/hadamard.m
## trying to save that buffer in vim results in
## Can't open file for writing


Mike Miller <mtmiller>
Group Member
Sat 04 Apr 2015 06:02:00 PM UTC, comment #6: 

I can't reproduce this.  Can you try running with the '-f' option and see if it still gives an error?


./run-octave -f
edit hadamard.m



Rik <rik5>
Group administrator
Sat 04 Apr 2015 05:59:40 PM UTC, comment #5: 

I think this is essentially a duplicate of bug #41278, any reason not to close this as a duplicate and move discussion/patches to that report?

Mike Miller <mtmiller>
Group Member
Sat 04 Apr 2015 05:57:25 PM UTC, comment #4: 

See also bug #41278.

Mike Miller <mtmiller>
Group Member
Sat 04 Apr 2015 05:56:36 PM UTC, comment #3: 

The HOME that edit.m talks about is not the same as the $HOME environment variable.

This is an old feature of edit.m that differs from Matlab I think, and probably isn't used much these days. The intent, I think, was to allow you to edit an m-file even if you don't have write permission. If the file is not writable, e.g. part of Octave's system path, it would copy it to your writable HOME directory, which is also supposed to be in your load path, and that copy would then override the one in the system path.

If you set the EDITINPLACE variable to true, it will open the non-writeable file in your editor anyway without making a copy.

I asked about some bugs in edit.m when I first started working with Octave and got the impression that a lot of these features are legacy and could probably be deprecated. E.g. we might make EDITINPLACE true by default, deprecate it, and remove it at some point.

IMHO these are more sensible defaults:


>> edit editinplace true
>> edit home .


Mike Miller <mtmiller>
Group Member
Sat 04 Apr 2015 05:38:47 PM UTC, comment #2: 

The doc says: "If `NAME.ext' is not modifiable, it will be copied to `HOME' before editing."

This is inaccurate, since the file copied to $HOME/octave and not to $HOME directly (which would be even worse in my opinion).


((My initial message sounds weird because I initially intended to send an email to the maintainers list, which is why I wrote "should I file a bug report for this", and then copy-pasted it a little too fast...))

Julien Bect <jbect>
Sat 04 Apr 2015 05:20:22 PM UTC, comment #1: 

I think this is a bug.  There's no need to open a path/file without the user intending to do so.  I'd say just open the file, perhaps with a dialog notice saying it isn't editable but can be saved elsewhere or maybe some other indication such as a grey background.  If the user attempts to save the file then the system should complain.

Dan Sebald <sebald>
Sat 04 Apr 2015 04:30:00 PM UTC, original submission:  

I get the following error (on hg rev cf9b94a89620) when trying to open hadamard.m (which is a protected file) from the GUI by typing "edit hadamard".

>> edit hadamard

cp: cannot create regular file '/home/high/bect/octave/hadamard.m': No such file or directory

/home/high/bect is my HOME directory and I don't have a ~/octave subdirectory.

Of course, the problem disappears if I create ~/octave but is this really the expected behaviour, or should I file a bug report for this ?

Proposed fixes : either create ~/octave when it does not exist, or instead create the copy of hadamard.m in /tmp ?

@++
Julien

Julien Bect <jbect>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by sebald (Posted a comment)
  • -email is unavailable- added by jbect (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-06-02 jwe Release4.0.0-rc2 4.0.0
    2015-04-07 rik5 Open/ClosedOpen Closed
    2015-04-04 rik5 StatusNone Duplicate
    2015-04-04 rik5 Dependencies- Depends on bugs #41278
    2015-04-04 rik5 StatusDuplicate None
    2015-04-04 mtmiller StatusNone Duplicate

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code