darcs

Issue 2120 Darcs fails to invoke an editor under MS Windows

Title Darcs fails to invoke an editor under MS Windows
Priority bug Status resolved
Milestone Resolved in 2.10.0
Superseder Nosy List mulander
Assigned To
Topics

Created on 2012-01-12.20:15:13 by mulander, last changed 2012-07-23.12:22:01 by kowey.

Messages
msg14984 (view) Author: mulander Date: 2012-01-12.20:15:10
Darcs fails to invoke an editor on MS Windows Vista and MS Windows Vista XP.

I have gvim and vim on the system. Both work from cmd.exe and powershell.
I do not have 'vi' installed and it can't be called from cmd.exe and powershell.
I also think that 'notepad.exe' is a saner default for windows than calling 'edit'.

Transcript from powershell/cmd.exe (they have exactly the same outcome):
PS D:\> mkdir test


    Directory: D:\


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----        2012-01-12     21:01            test


PS D:\> cd test
PS D:\test> darcs init
PS D:\test> touch file
PS D:\test> darcs add file
PS D:\test> darcs record
Each patch is attributed to its author, usually by email address (for
example, `Fred Bloggs <fred@example.net>').  Darcs could not determine
your email address, so you will be prompted for it.

Your address will be stored in _darcs/prefs/author.
It will be used for all patches recorded in this repository.
If you move that file to ~/.darcs/author, it will be used for patches
you record in ALL repositories.
What is your email address? spam @ prevention . fake
addfile ./file
Shall I record this change? (1/1)  [ynW...], or ? for more options: y
What is the patch name? Test patch
Do you want to add a long comment? [yn]y
Nazwa 'vi' nie jest rozpoznawana jako polecenie wewnętrzne lub zewnętrzne,
program wykonywalny lub plik wsadowy.
File content did not change. Continue anyway? [yn]n
Aborted.


PS D:\test> darcs --exact-version
darcs compiled on Mar 14 2011, at 23:17:58

Context:

[TAG 2.5.2
Ganesh Sittampalam <ganesh@earth.li>**20110313223504
 Ignore-this: f3f57f3eacb2fdd4cdafc581c05058e3
]

Compiled with:

HTTP-4000.0.9
array-0.3.0.1
base-4.2.0.2
bytestring-0.9.1.7
containers-0.3.0.0
directory-1.0.1.1
extensible-exceptions-0.1.1.1
filepath-1.1.0.4
hashed-storage-0.5.5
haskeline-0.6.3.2
html-1.0.1.2
mtl-1.1.0.2
network-2.2.1.7
old-time-1.0.0.5
parsec-2.1.0.1
process-1.0.1.3
random-1.0.0.2
regex-compat-0.93.1
regex-posix-0.94.4
tar-0.3.1.0
text-0.11.0.5
unix-compat-0.2.1.1
zlib-0.5.2.0
PS D:\test> vim
PS D:\test>
msg14992 (view) Author: ganesh Date: 2012-01-13.07:29:10
issue1465 has some of the history of the current behaviour. I suspect that 
we need to have a completely different test to identify "didn't exist" on 
Windows.
msg15127 (view) Author: mulander Date: 2012-02-19.15:30:01
Prelude> System.Process.system "vi"
Loading package bytestring-0.9.1.10 ... linking ... done.
Loading package Win32-2.2.0.1 ... linking ... done.
Loading package filepath-1.2.0.0 ... linking ... done.
Loading package old-locale-1.0.0.2 ... linking ... done.
Loading package old-time-1.0.0.6 ... linking ... done.
Loading package directory-1.1.0.0 ... linking ... done.
Loading package process-1.0.1.5 ... linking ... done.
Nazwa 'vi' nie jest rozpoznawana jako polecenie wewnętrzne lub zewnętrzne,
program wykonywalny lub plik wsadowy.
ExitFailure 1
msg15128 (view) Author: mulander Date: 2012-02-19.17:34:38
The root cause of the problem is System.Process.system returning
ExitFailure 1 when the called program does not exist.

Exec.hs and Utils.hs both contain code to handle possible 127 and 126
return code which stand for program not found and not executable (no
permission to execute) and the code would probably work correctly if the
command was called with System.Process.runProcess but instead Exec.hs on
line 153 uses System.Process.system which on MS Windows returns
ExitFailure 1 even though the system %ERRORLEVEL% after such call in
cmd.exe is set to 9009.

Here is the code I am referring to.

#else

execInteractive cmd arg = withoutProgress $ do
  system $ cmd ++ " " ++ arg
#endif

Code that takes/should take part in the action:

Exec.hs:
withExit127 - not used.
notFoundError - not used.

Utils.hs:
ortryrunning - never sees 126, 127 - gets ExitFailure 1 so doesn't try
other commands from the chain.
runEditor - could be extended with "notepad" path before trying "edit".
msg15130 (view) Author: mulander Date: 2012-02-19.20:16:06
I provided patch724 to solve this issue.
msg15157 (view) Author: noreply Date: 2012-02-23.20:28:59
The following patch sent by Adam Wolk <netprobe@gmail.com> updated issue issue2120 with
status=has-patch

* resolve issue2120 
Ignore-this: 4c87e715b9016ecdb336228015e3f084
msg15574 (view) Author: noreply Date: 2012-04-20.16:56:03
The following patch sent by Adam Wolk <netprobe@gmail.com> updated issue issue2120 with
status=resolved;resolvedin=2.10.0 HEAD

* resolve issue2120 
Ignore-this: 4c87e715b9016ecdb336228015e3f084
History
Date User Action Args
2012-01-12 20:15:13mulandercreate
2012-01-13 07:29:12ganeshsetpriority: bug
messages: + msg14992
2012-02-19 15:30:02mulandersetmessages: + msg15127
2012-02-19 17:34:39mulandersetmessages: + msg15128
2012-02-19 20:16:07mulandersetstatus: unknown -> has-patch
messages: + msg15130
2012-02-23 20:29:00noreplysetmessages: + msg15157
2012-04-20 16:56:05noreplysetstatus: has-patch -> resolved
messages: + msg15574
resolvedin: 2.10.0
2012-07-23 12:19:58RobertPattinsonsetstatus: resolved -> unknown
messages: + msg15917
2012-07-23 12:20:56koweysetmessages: - msg15917
2012-07-23 12:22:01koweysetstatus: unknown -> resolved