natverse / nat

NeuroAnatomy Toolbox: An R package for the (3D) visualisation and analysis of biological image data, especially tracings of single neurons.
https://natverse.org/nat/
64 stars 29 forks source link

issues calling CMTK binaries in windows 7 #292

Closed dpacheco0921 closed 8 years ago

dpacheco0921 commented 8 years ago

Hi

I think I found a bug (windows 7). When you do cmtk.bindir(check = true) it fails, because it looks for 'gregxform', but if I change it to 'gregxform.exe', it works. However there are other pieces of the code that have the same bug (for example xformpoints). So I think that any part of the code that is calling a CMTK function without the '.exe' suffix will fail. Do you mind checking this?

Thanks

Diego

jefferis commented 8 years ago

Hi Diego,

You are almost certainly right - I have never used CMTK as a regular Windows install and only a few times with Cygwin.

The issue as you say must be with the cmtk.bindir function which is used internally whenever CMTK is called. There will need to be different default behaviour on Windows. Could you file a bug report on GitHub?

Best,

Greg.

Sent from my iPhone

On 14 Mar 2016, at 19:48, dpacheco0921 notifications@github.com wrote:

Hi

I think I found a bug (windows 7). When you do cmtk.bindir(check = true) it fails, because it looks for 'gregxform', but if I change it to 'gregxform.exe', it works. However there are other pieces of the code that have the same bug (for example xformpoints). So I think that any part of the code that is calling a CMTK function without the '.exe' suffix will fail. Do you mind checking this?

Thanks

Diego

— Reply to this email directly or view it on GitHub.

dpacheco0921 commented 8 years ago

Hi Greg

Sorry, I am new to GiHub, and I don't know what you mean by filing a bug report. What exactly should I do?

Diego

jefferis commented 8 years ago

Sorry – I was reading on my phone. You've done what you need to do! I just need to try and push a fix that you can test. Best,

Greg.

jefferis commented 8 years ago

Hi Diego,

can you tell me what happens when you do:

Sys.which("gregxform")
Sys.which("gregxform.exe")
Sys.which("cmtk")

on your machine. And if you know exactly which cmtk version (version number, target platform) you installed that wold be helpful.

Best, Greg.

dpacheco0921 commented 8 years ago

cmtk.bindir() [1] "C:/PROGRA~1/CMTK-3.3/CMTK/lib/cmtk/bin"

Sys.which("gregxform") gregxform "C:\PROGRA~1\CMTK-3.3\CMTK\lib\cmtk\bin\GREGXF~1.EXE" Sys.which("gregxform.exe") gregxform.exe "C:\PROGRA~1\CMTK-3.3\CMTK\lib\cmtk\bin\GREGXF~1.EXE" Sys.which("cmtk") cmtk ""

dpacheco0921 commented 8 years ago

I used the latest version for windows: CMTK-3.3.1-Windows-AMD64

jefferis commented 8 years ago

Great. thank you. And did you do anything to ensure that directory was in your path after installation?

Sent from my iPhone

On 16 Mar 2016, at 02:24, dpacheco0921 notifications@github.com wrote:

cmtk.bindir() [1] "C:/PROGRA~1/CMTK-3.3/CMTK/lib/cmtk/bin"

Sys.which("gregxform") gregxform "C:\PROGRA~1\CMTK-3.3\CMTK\lib\cmtk\bin\GREGXF~1.EXE" Sys.which("gregxform.exe") gregxform.exe "C:\PROGRA~1\CMTK-3.3\CMTK\lib\cmtk\bin\GREGXF~1.EXE" Sys.which("cmtk") cmtk ""

— You are receiving this because you commented. Reply to this email directly or view it on GitHub

jefferis commented 8 years ago

One last thing, could you tell me the output of running:

sessionInfo()
Sys.info()
.Platform

Many thanks.

dpacheco0921 commented 8 years ago

Do you mean to environmental variable PATH?, if so, yes.

sessionInfo() R version 3.2.4 (2016-03-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages: [1] stats graphics grDevices utils datasets methods
[7] base

other attached packages: [1] nat.flybrains_1.6 nat.templatebrains_0.6.2 [3] nat_1.8.1 rgl_0.95.1441

loaded via a namespace (and not attached): [1] magrittr_1.5 tools_3.2.4 igraph_1.0.1
[4] rappdirs_0.3 yaml_2.1.13 nat.utils_0.5.1 [7] Rcpp_0.12.3 filehash_2.3 codetools_0.2-14 [10] nabor_0.4.6 digest_0.6.9

Sys.info() sysname release "Windows" "7 x64" version nodename "build 7601, Service Pack 1" "MURTHY-138PR22" machine login "x86-64" "diego" user effective_user "diego" "diego" .Platform $OS.type [1] "windows"

$file.sep [1] "/"

$dynlib.ext [1] ".dll"

$GUI [1] "RStudio"

$endian [1] "little"

$pkgType [1] "win.binary"

$path.sep [1] ";"

$r_arch [1] "x64"

jefferis commented 8 years ago

Thanks for all that. And how did you set the PATH?

jefferis commented 8 years ago

Incidentally I should have said this already, but your best workaround until there is a proper fix is to set

options(nat.cmtk.bindir="C:\PROGRA~1\CMTK-3.3\CMTK\lib\cmtk\bin")

in your .Rprofile file. See e.g.

http://www.statmethods.net/interface/customizing.html

dpacheco0921 commented 8 years ago

I went to system properties, then to environmental variables, then edited the variable PATH, basically adding the directory of the CMTK binaries: "C:\Program Files\CMTK-3.3\CMTK\lib\cmtk\bin"

jefferis commented 8 years ago

Thanks. Can you try one more thing for me. Can you add:

C:\Program Files\CMTK-3.3\CMTK\bin

to the path.

dpacheco0921 commented 8 years ago

Hi Greg

I added C:\Program Files\CMTK-3.3\CMTK\bin, to the path too, and also edited the .Rprofile file, but it does still give me the same error:

Error in cmtk.bindir(check = TRUE) : cmtk is not installed at:C:/PROGRA~1/CMTK-3.3/CMTK/lib/cmtk/bin Please check value of options('nat.cmtk.bindir')

Diego

jefferis commented 8 years ago

Dear Diego, Sorry for the long delay in fixing this, but many other commitments recently and one needs to be careful to avoid breakage on other platforms. In any case, I would be grateful if you could test that installing the fix/cmtk-win branch works for you. You can install as follows:

devtools::install_github("jefferis/nat@fix/cmtk-win")

Thanks, Greg.

dpacheco0921 commented 8 years ago

Hi Greg,

When I run it:

Downloading GitHub repo jefferis/nat@fix/cmtk-win from URL https://api.github.com/repos/jefferis/nat/zipball/fix/cmtk-win Installing nat "C:/PROGRA~1/R/R-32~1.4/bin/x64/R" --no-site-file --no-environ --no-save --no-restore CMD \ INSTALL \ "C:/Users/diego/AppData/Local/Temp/Rtmp0Kxag3/devtools1288e2f4417/jefferis-nat-d0029eb" \ --library="C:/Users/diego/Documents/R/win-library/3.2" --install-tests

Loading required package: rgl

Attaching package: 'nat'

The following objects are masked from 'package:base':

intersect, setdiff, union

Loading required package: nat.templatebrains

I get an Error (the last line), what does it mean?, also, I tried running the demo and I still get the same error with CMTK.

jefferis commented 8 years ago

In the first instance you need to restart R. Then run the install_github cud without loading any additional packages.

Updating a loaded package is often problematic - in this case it is unable to load the newly installed / updated version of nat.

You may then find that there are a new class of Windows-specific errors, but that would be progress ...

Sent from my iPhone

On 29 Mar 2016, at 23:01, dpacheco0921 notifications@github.com wrote:

Hi Greg,

When I run it:

Downloading GitHub repo jefferis/nat@fix/cmtk-win from URL https://api.github.com/repos/jefferis/nat/zipball/fix/cmtk-win Installing nat "C:/PROGRA~1/R/R-32~1.4/bin/x64/R" --no-site-file --no-environ --no-save --no-restore CMD \ INSTALL \ "C:/Users/diego/AppData/Local/Temp/Rtmp0Kxag3/devtools1288e2f4417/jefferis-nat-d0029eb" \ --library="C:/Users/diego/Documents/R/win-library/3.2" --install-tests

Loading required package: rgl

Attaching package: 'nat'

The following objects are masked from 'package:base':

intersect, setdiff, union Loading required package: nat.templatebrains

installing source package 'nat' ... * R * data ** moving datasets to lazyload DB * inst * tests * preparing package for lazy loading Error: package 'nat' is required by 'nat.templatebrains' so will not be detached removing 'C:/Users/diego/Documents/R/win-library/3.2/nat' restoring previous 'C:/Users/diego/Documents/R/win-library/3.2/nat' Error: Command failed (1) I get an Error (the last line), what does it mean?, also, I tried running the demo and I still get the same error with CMTK.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub

dpacheco0921 commented 8 years ago

Hi Greg

Sorry for the belated reply, so I tried as you described, and I get an error when trying to bridge a neuron:

neuron_in_jfrc2 <- xform_brain(neuron_to_bridge, FCWB, JFRC2) Error in cmtk.streamxform(points, reg, direction, transformtype) : Error running CMTK streamxform! In addition: Warning message: running command '"C:/PROGRA~1/CMTK-3.3/CMTK/lib/cmtk/bin/streamxform" -- --inverse C:\Users\diego\AppData\Local\rpkg-nat.templatebrains\regfolders\09ea2745e48f45dd70e311a577c8d5414aea2ce5/JFRC2_FCWB.list' had status 1

jefferis commented 8 years ago

Hi Diego,

Have you installed the latest update of this branch?

devtools::install_github("jefferis/nat@fix/cmtk-win")

Although I can't test on Windows myself at the moment, I did fix some issues that I know would cause trouble on Windows in the last couple of days, including this:

https://github.com/jefferis/nat/commit/077e32e48c013032ee00160aa7e059740d50c66b

5 days ago.

dpacheco0921 commented 8 years ago

Yes I did install the last version (updated it today).

Diego

jefferis commented 8 years ago

Can you try and run the command directly from the Windows command line to report what the streamxform error is?

i.e.

"C:/PROGRA~1/CMTK-3.3/CMTK/lib/cmtk/bin/streamxform" -- --inverse C:\Users\diego\AppData\Local\rpkg-nat.templatebrains\regfolders\09ea2745e48f45dd70e311a577c8d5414aea2ce5/JFRC2_FCWB.list
dpacheco0921 commented 8 years ago

Hi greg

The command has a mistake (check the beginning and end of bold text)

"C:/PROGRA~1/CMTK-3.3/CMTK/lib/cmtk/bin/streamxform" -- --inverse C:\Users\diego\AppData\Local\rpkg-nat.templatebrains\regfolders# \09ea2745e48f45dd70e311a577c8d5414aea2ce5/JFRC2_FCWB.list

If I fix that, it works

"C:/PROGRA~1/CMTK-3.3/CMTK/lib/cmtk/bin/streamxform" -- --inverse C:\Users\diego\AppData\Local\rpkg-nat.templatebrains\regfolders\09ea2745e48f45dd70e311a577c8d5414aea2ce5\JFRC2_FCWB.list

Diego

jefferis commented 8 years ago

Interesting. so just to be clear, the problem is that there are mixed path separators (forward and backslash). I'll have to try to track down where they are getting put together. I have pushed a possible fix to the nat.templatebrains package in a new branch. You can install with

install_github('jefferislab/nat.templatebrains@fix/win-paths')
dpacheco0921 commented 8 years ago

Hi greg, The fix works, in generating the right command (same separators). However I am having some issues with the function streamxform, when I run the command: streamxform -- --inverse C:\Users\diego\AppData\Local\rpkg-nat.templatebrains\regfolders\09ea2745e48f45dd70e311a577c8d5414aea2ce5\JFRC2_FCWB.list, it says it can read or find the file, even though I can cd to it (so the folder exists). Let me check some things (permissions to folders or executable files, etc) and I will get back to you. Diego

jefferis commented 8 years ago

After quite a bit of experimentation and some help from visitors including @istvantaisz, we have been able to make everything work properly – but only with the cygwin distribution of cmtk, not the regular Windows package. This means installing cygwin along with fftw3 (a dependency of cmtk that can be installed at setup), installing the CMTK cygwin distribution; it also appeared to be necessary to copy c:\cygwin64\cyg*.dll to C:\Windows\System32 and/or C:\Windows\SysWOw64.

jefferis commented 8 years ago

Note that the fixes mentioned are now included in v1.8.5 of nat (what you will get if you devtools::install_github from this repo, rather than what you get from CRAN via install.packages.

jefferis commented 8 years ago

Closing because we will only support cygwin cmtk going forwards.