bugGNU Octave - Bugs: bug #56454, [octave forge] (io) xlswrite...

 
 

bug #56454: [octave forge] (io) xlswrite creates invalid file when GUI is disabled or not available

Submitter:  Georg Wiora <gwiora>
Submitted:  Fri 07 Jun 2019 07:17:37 AM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  lostbard
Originator Name:  gwiora Open/Closed:  * Closed
Release:  * 5.1.0 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 26 Sep 2019 03:26:28 PM UTC, comment #17: 

Closing as fixed

John Donoghue <lostbard>
Group Member
Wed 12 Jun 2019 09:03:55 PM UTC, comment #16: 

Ah.
Yes my mxe build tree itself lags somewhat behind + I never use octave-cli.
Thanks for the pointers.

Philip Nienhuis <philipnienhuis>
Group Member
Wed 12 Jun 2019 08:11:05 PM UTC, comment #15: 

You need to apply the patch referenced from comment 9, whih was for a similar issue, and then add the \


John Donoghue <lostbard>
Group Member
Wed 12 Jun 2019 05:27:22 PM UTC, comment #14: 

Which octave.bat file are we talking about?

In the <Octave-5.1.0.0/mingw64/bin/> subdir on my box there is one (plus an identical octave-5.1.0.bat) but those haven't got any lines a la "set MSYSPATH ...."

BTW it never occurred to me that the files helping to initialize the GUI would make the difference. Good catch.

Philip Nienhuis <philipnienhuis>
Group Member
Wed 12 Jun 2019 04:27:45 PM UTC, comment #13: 
John Donoghue <lostbard>
Group Member
Wed 12 Jun 2019 02:29:21 PM UTC, comment #12: 

You saved my day John!

After applying your fix to octave.bat xlswrite is running like expected!

Excellent work.

I recommend changing the status of this entry from "Works for me" to "confirmed" and apply your patch to octave.bat.


Georg Wiora <gwiora>
Wed 12 Jun 2019 02:15:50 PM UTC, comment #11: 

I always run i from teh command prompt from the octave installed shortcuts - Im gguessing you are not doing that.

in octave, when running octave.bat:

octave:4> system('where zip')
C:\Octave\Octave-5.1.1\usr\bin\zip.exe
ans = 0

Via a standalone CMD:

octave:1> system('where zip')
INFO: Could not find files for the given pattern(s).
ans =  1


Looking at the paths, using getenv, the msys2 path isn't correct.
In octave.bat change the 2 lines that are:

set MSYSPATH=%ROOT_PATH%usr

to

set MSYSPATH=%ROOT_PATH%usr\

(added '\' at end of the line)






John Donoghue <lostbard>
Group Member
Wed 12 Jun 2019 12:55:06 PM UTC, comment #10: 

Tanks John! I tried the patched version of octave.bat, without success.
I thought I may have some kind of software installed or in my path that conflicts with octave.

To verify this I opened a new shell and defined a very clean path variable:


 set PATH="C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\"


The I ran the original and the patched version of octave.bat with the same result:


c:> octave.bat --no-gui
GNU Octave, version 5.1.0
[...]
Octave was configured for "x86_64-w64-mingw32".
[...]

octave:1> pkg load io
octave:2> xlswrite('test-cli.xlsx',{1;2;3;4},'abc','a1:a4','OCT')
Checking requested interface(s):
OCT*; (* = default interface)
Der Befehl "unzip" ist entweder falsch geschrieben oder
konnte nicht gefunden werden. (English: Command "unzip" could not be found)
file test-cli.xlsx couldn't be unpacked. Is it the proper file format?
warning: UnZip failed with error 1
Output:
error: warning: STATE structure must have fields 'identifier' and 'state'
error: called from
    __OCT_spsh_open__ at line 72 column 7
    xlsopen at line 316 column 35
    xlswrite at line 205 column 9


To my understanding this should not happen, because octave.bat should have set up all paths correctly.

Am I doing anything wrong or is the problem in the configuration of octave.bat?

Georg Wiora <gwiora>
Wed 12 Jun 2019 12:30:04 PM UTC, comment #9: 

Maybe related to  https://savannah.gnu.org/bugs/?56416 ?

The patch to octave.bat there may fix it


John Donoghue <lostbard>
Group Member
Wed 12 Jun 2019 11:44:28 AM UTC, comment #8: 

Ok, sorry, then I must have misread this

> Finally I tried to run "octave.bat --no-gui" instead of "octave-cli.exe" and got the same results for xlsx-test.


in your comment #5. I thought you meant that was a resolution, but maybe instead you meant that there was no change.

I don't have access to Windows to test or suggest anything, just thought I could help by pointing out that running the .exe directly without anything set in the environment first is not supported.

Mike Miller <mtmiller>
Group Member
Wed 12 Jun 2019 11:01:54 AM UTC, comment #7: 

Thanks for your help Mike. Running octave.bat does not fix the issue in my place. I will try on another machine.

Georg Wiora <gwiora>
Wed 12 Jun 2019 10:57:58 AM UTC, comment #6: 


> Any hints out there?


Are you looking for a hint other than "use octave.bat"? Because I believe running the .exe files directly on Windows is not supported. It is agreed that certain environment variables and settings must be done before running the programs, and that is the reason for the .bat and .vbs scripts.

If using octave.bat fixes this difference, which is what I think I read, then maybe there is no bug here.

Mike Miller <mtmiller>
Group Member
Wed 12 Jun 2019 09:51:43 AM UTC, comment #5: 

I found different behavior between gui and cli. My conclusion was, if the io package is not the cause of the problem, it may be ZIP functions that it is relying on. This is at least plausible, because it is only a missing file that corrupts the xlsx files. Zip function is part of octave core AFAIK.

Differences I found between octave-cli.exe (executed in cmd.exe) and octave-gui.vbs (started from windows surface):

  • CLI does not know perl path (windows 7).


After adding .../Octave/usr/bin to the windows path at least "help zip" was working

Then I tried the following command:


zip('test.zip',{'test.fig';'test.log'})


This worked on gui and failed on cli with the following output:


octave:4> zip('test.zip',{'test.fig';'test.log'})
zip I/O error: Invalid argument

zip error: Could not create output file ('[absolute_path_removed]/Spielplatz/test.zip')
error: zip: zip failed with exit status = 15
error: called from
    zip at line 75 column 5


Using the windows "where" command I found an older version of ZIP.exe shadowing ZIP.exe inside octave installation.

After removing this problem by cleaning up my path variables the xlsx problem still persists.

I suspected different path setup inside octave. getenv('PATH') produced nearly the same result in cli and gui with the little difference that the GUI delivered the shortened dos path

  • GUI: C:\Octave\OCTAVE~2.0\mingw64\bin
  • CLI: C:\Octave\Octave-5.1.0.0\mingw64\bin


and gui had prefixed the following paths to the PATH variable:

  • C:\Octave\OCTAVE~2.0\mingw64\qt5\bin
  • C:\Octave\OCTAVE~2.0\mingw64\bin


Finally I tried to run "octave.bat --no-gui" instead of "octave-cli.exe" and got the same results for xlsx-test. Checking the path variables showed that now the "...\mingw64\qt5\bin" and the "...\mingw64\bin" paths had been prefixed to PATH variable...

Here ended my ideas where to look further...

Any hints out there?

Georg Wiora <gwiora>
Wed 12 Jun 2019 08:44:55 AM UTC, comment #4: 

I have no change of behavior after a complete reinstall. I still get corrupted xlsx files when using octave-cli.
I have not tried the 64-64 version yet.

Georg Wiora <gwiora>
Wed 12 Jun 2019 07:50:54 AM UTC, comment #3: 

I have tried reinstalling the relevant packages (in new disk locations). That did not make a difference. I will now try to reinstall octave in total.

A run of __run_test_suite_.m_ did not show any significant problems.

Georg Wiora <gwiora>
Fri 07 Jun 2019 02:29:12 PM UTC, comment #2: 

Works for me with Octave-5.1.0.0 (I guess one I d/led it from ftp.gnu.org) and Octave-6.0.0.

Which installer (exact name) did you use?

I do not doubt your observation but I really fail to see what the GUI would have to do with spreadsheet I/O. Those are completely unrelated parts of the code.
Therefore my guess is that your Octave installation simply got corrupted.

In a sense this looks like bug #56373, where also seemingly unrelated issue appeared (although I could reproduce that one).

I suggest you reinstall Octave (maybe take the 64-64 version) and try again. First rename the old installaton directory (prepend an underscore0, then run uninstall.exe from that directory. That way you're sure to not re-use hard disk parts occupied by your possibly corrupt installation.

Maybe you can try to run _run_test_suite_.m (takes quite a bit of time) and see if that gives additional clues.

Philip Nienhuis <philipnienhuis>
Group Member
Fri 07 Jun 2019 09:40:19 AM UTC, comment #1: 

An even better title for this bug would be:

"[octave forge] (io) xlswrite creates invalid file when GUI is disabled or not available"

Georg Wiora <gwiora>
Fri 07 Jun 2019 07:17:37 AM UTC, original submission:  

When I run the following command in octave-gui


xlswrite('test-gui.xlsx',{1;2;3;4},'abc','a1:a4','OCT')


I get a correctly written xlsx file that I can open in excel.

If I run the same command in octave-cli or in octave-gui --no-gui the result is a corrupted xlsx file.


xlswrite('test-cli.xlsx',{1;2;3;4},'abc','a1:a4','OCT')



To be able to run octave-gui from shell I have set these additional environment variables:


set QT_PLUGIN_PATH=C:\Octave\Octave-5.1.0.0\mingw64\qt5\plugins
set PATH=%PATH%;C:\Octave\Octave-5.1.0.0\mingw64\qt5\bin


I compared the contents of the excel files by unzipping and found that the invalid file is missing the file "[Content_Types].xml".

Copying this file from a working to an invalid file, makes it working.

I have attached both files.

Georg Wiora <gwiora>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #47048:  test_cli.xlsx added by gwiora (7KiB - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet - test_gui is the working file and test_cli the defective)
file #47049:  test_gui.xlsx added by gwiora (7KiB - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet - test_gui is the working file and test_cli the defective)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by lostbard (Posted a comment)
  • -email is unavailable- added by siko1056 (Updated the item)
  • -email is unavailable- added by gwiora (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 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-09-26 lostbard StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2019-06-12 lostbard StatusWorks For Me Ready For Test
        Assigned toNone lostbard
    2019-06-07 philipnienhuis StatusNone Works For Me
    2019-06-07 siko1056 Summary[octave forge] (io) xlswrite creates invalid file when using in octave-cli but works in octave-gui [octave forge] (io) xlswrite creates invalid file when GUI is disabled or not available
    2019-06-07 siko1056 Summaryxlswrite creates invalid file when using in octave-cli but works in octave-gui [octave forge] (io) xlswrite creates invalid file when using in octave-cli but works in octave-gui
    2019-06-07 gwiora Attached File- Added test_cli.xlsx, #47048
        Attached File- Added test_gui.xlsx, #47049

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code