Subject: bug#13921: 24.2; Misbehavior of expand-file-name on Cygwin with Emacs 24.2

From: Barry OReilly <[email-masked]>
Date: Sun, 10 Mar 2013 22:03:31 -0400

When I attempted to build CEDET from their bzr trunk (revno 8498), the
build failed due to expand-file-name function returning an incorrect "d:"
prefix.  Under other conditions expand-file-name returns the correct "c:"
prefix.  Some command line IO will illustrate:

[CEDET build issues this:]
 emacs -batch --no-site-file --eval '(setq debug-on-error t)' -l
"../../cedet-remove-builtin.el" -L . --eval '(progn (require (quote
cedet-compat)) (require (quote mode-local)))' -L ../eieio/ -L ./ -L ./
--eval '(progn  (setq generated-autoload-file
"/home/epich/sw/cedet/lisp/cedet/loaddefs.el"))' -f batch-update-autoloads
/home/epich/sw/cedet/lisp/cedet
Debugger entered--Lisp error: (file-error "Opening output file" "no such
file or directory" "d:/home/epich/sw/cedet/lisp/cedet/loaddefs.el")
  write-region(";;; loaddefs.el --- automatically extracted
autoloads\n;;\n;;; Code:\n\n\f\n(provide 'loaddefs)\n;; Local
Variables:\n;; version-control: never\n;; no-byte-compile: t\n;;
no-update-autoloads: t\n;; coding: utf-8\n;; End:\n;;; loaddefs.el ends
here\n" nil "d:/home/epich/sw/cedet/lisp/cedet/loaddefs.el")

autoload-ensure-default-file("d:/home/epich/sw/cedet/lisp/cedet/loaddefs.el")
  autoload-find-generated-file()
  update-directory-autoloads("/home/epich/sw/cedet/lisp/cedet")
  apply(update-directory-autoloads "/home/epich/sw/cedet/lisp/cedet")
  batch-update-autoloads()
  command-line-1(("--eval" "(setq debug-on-error t)" "-l"
"../../cedet-remove-builtin.el" "-L" "." "--eval" "(progn (require (quote
cedet-compat)) (require (quote mode-local)))" "-L" "../eieio/" "-L" "./"
"-L" "./" "--eval" "(progn  (setq generated-autoload-file
\"/home/epich/sw/cedet/lisp/cedet/loaddefs.el\"))" "-f"
"batch-update-autoloads" "/home/epich/sw/cedet/lisp/cedet"))
  command-line()
  normal-top-level()

Comparing the backtrace above with the source code, it's evident
expand-file-name prepended the "d:" to the filename to get:
"d:/home/epich/sw/cedet/lisp/cedet/loaddefs.el".

However, when I evaluate (expand-file-name
"/home/epich/sw/cedet/lisp/cedet") in the the scratch, I get
"c:/home/epich/sw/cedet/lisp/cedet".  I edited CEDET's Emacs command above
to exclude -f batch-update-autoloads and added a debug statement:

emacs -batch --no-site-file --eval '(setq debug-on-error t)' -l
"../../cedet-remove-builtin.el" -L . --eval '(progn (require (quote
cedet-compat)) (require (quote mode-local)))' -L ../eieio/ -L ./ -L ./
--eval '(progn  (setq generated-autoload-file
"/home/epich/sw/cedet/lisp/cedet/loaddefs.el") (message "DEBUG: expanded
file name is %s" (expand-file-name "/home/epich/sw/cedet/lisp/cedet")))'
/home/epich/sw/cedet/lisp/cedet
DEBUG: expanded file name is c:/home/epich/sw/cedet/lisp/cedet

This is as far as I investigated the bug.

I'm using the Emacs 24.2 Windows distribution, invoked within Cygwin:

epich@laptop02 ~/sw/cedet/lisp/cedet $ ls -l `which emacs`
lrwxrwxrwx 1 epich None 51 Nov  5 22:02 /home/epich/bin/emacs ->
/cygdrive/c/Users/epich/sw/emacs-24.2/bin/emacs.exe
epich@laptop02 ~/sw/cedet/lisp/cedet $ uname -srv
CYGWIN_NT-6.1-WOW64 1.7.17(0.262/5/3) 2012-10-19 14:39

In GNU Emacs 24.2.1 (i386-mingw-nt6.1.7601)
 of 2012-08-28 on MARVIN
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --with-gcc (4.6) --cflags
 -ID:/devel/emacs/libs/libXpm-3.5.8/include
 -ID:/devel/emacs/libs/libXpm-3.5.8/src
 -ID:/devel/emacs/libs/libpng-dev_1.4.3-1/include
 -ID:/devel/emacs/libs/zlib-dev_1.2.5-2/include
 -ID:/devel/emacs/libs/giflib-4.1.4-1/include
 -ID:/devel/emacs/libs/jpeg-6b-4/include
 -ID:/devel/emacs/libs/tiff-3.8.2-1/include
 -ID:/devel/emacs/libs/gnutls-3.0.9/include'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  value of $XMODIFIERS: nil
  locale-coding-system: cp1252
  default enable-multibyte-characters: t

Major mode: Text

Minor modes in effect:
  shell-dirtrack-mode: t
  global-whitespace-mode: t
  evil-mode: t
  evil-local-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  show-paren-mode: t
  delete-selection-mode: t
  global-auto-revert-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
[snip]

Recent messages:
[snip]

Load-path shadows:
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/speedbar/speedbar hides
c:/Users/epich/sw/emacs-24.2/lisp/speedbar
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/speedbar/sb-image hides
c:/Users/epich/sw/emacs-24.2/lisp/sb-image
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/common/ezimage hides
c:/Users/epich/sw/emacs-24.2/lisp/ezimage
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/speedbar/dframe hides
c:/Users/epich/sw/emacs-24.2/lisp/dframe
~/.emacs.d/evil/lib/ert hides
c:/Users/epich/sw/emacs-24.2/lisp/emacs-lisp/ert
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/eieio/eieio hides
c:/Users/epich/sw/emacs-24.2/lisp/emacs-lisp/eieio
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/eieio/eieio-speedbar
hides c:/Users/epich/sw/emacs-24.2/lisp/emacs-lisp/eieio-speedbar
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/eieio/eieio-opt hides
c:/Users/epich/sw/emacs-24.2/lisp/emacs-lisp/eieio-opt
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/eieio/eieio-datadebug
hides c:/Users/epich/sw/emacs-24.2/lisp/emacs-lisp/eieio-datadebug
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/eieio/eieio-custom hides
c:/Users/epich/sw/emacs-24.2/lisp/emacs-lisp/eieio-custom
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/eieio/eieio-base hides
c:/Users/epich/sw/emacs-24.2/lisp/emacs-lisp/eieio-base
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/eieio/chart hides
c:/Users/epich/sw/emacs-24.2/lisp/emacs-lisp/chart
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/srecode/srecode hides
c:/Users/epich/sw/emacs-24.2/lisp/cedet/srecode
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/semantic/semantic hides
c:/Users/epich/sw/emacs-24.2/lisp/cedet/semantic
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/common/pulse hides
c:/Users/epich/sw/emacs-24.2/lisp/cedet/pulse
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/common/mode-local hides
c:/Users/epich/sw/emacs-24.2/lisp/cedet/mode-local
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/common/inversion hides
c:/Users/epich/sw/emacs-24.2/lisp/cedet/inversion
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/ede/ede hides
c:/Users/epich/sw/emacs-24.2/lisp/cedet/ede
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/common/data-debug hides
c:/Users/epich/sw/emacs-24.2/lisp/cedet/data-debug
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/common/cedet hides
c:/Users/epich/sw/emacs-24.2/lisp/cedet/cedet
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/common/cedet-idutils
hides c:/Users/epich/sw/emacs-24.2/lisp/cedet/cedet-idutils
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/common/cedet-global hides
c:/Users/epich/sw/emacs-24.2/lisp/cedet/cedet-global
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/common/cedet-files hides
c:/Users/epich/sw/emacs-24.2/lisp/cedet/cedet-files
c:/Users/epich/AppData/Roaming/.emacs.d/cedet-1.1/common/cedet-cscope hides
c:/Users/epich/sw/emacs-24.2/lisp/cedet/cedet-cscope

Features:
(shadow sort gnus-util mail-extr emacsbug message rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils thingatpt eieio-opt help-mode view mule-util vc-dispatcher
vc-bzr org-wl org-w3m org-vm org-rmail org-mhe org-mew org-irc
org-jsinfo org-infojs org-html org-exp ob-exp org-exp-blocks org-agenda
org-info org-gnus org-docview org-bibtex bibtex org-bbdb org
ob-emacs-lisp ob-tangle ob-ref ob-lob ob-table org-footnote org-src
ob-comint ob-keys ob ob-eval org-pcomplete org-list org-faces org-compat
org-entities org-macs format-spec cal-menu calendar cal-loaddefs
noutline outline easy-mmode semantic-edit semantic-make semanticdb-mode
semantic-decorate-include semanticdb-find semantic-decorate-mode
semantic-decorate pulse semantic-make-by make-mode shell pcomplete
dired-aux dired ffap semantic-el semantic-bovine bovine-debug
semantic-debug semantic-idle eldoc senator which-func semantic-imenu
semantic-sb imenu whitespace cus-start cus-load hippie-exp comint
regexp-opt ansi-color cedet cedet-contrib-load contrib-loaddefs
cogre-load cogre-loaddefs speedbar-load speedbar-loaddefs ede-load
ede-loaddefs ede-speedbar ede-files ede ede-base ede-auto eieio-speedbar
semantic-ia-sb semantic-analyze semantic-scope semantic-analyze-fcn
semantic-sort semanticdb-javap cedet-java semanticdb-el semanticdb-ref
semantic-find semanticdb semantic-ctxt semantic-format
semantic-util-modes semantic-util semantic semantic-lex semantic-tag-ls
semantic-tag working fame speedbar sb-image ezimage dframe easymenu
assoc eieio-custom wid-edit ede-source eieio-base srecode-load srecode
srecode-loaddefs semantic-load semantic-fw semantic-loaddefs mode-local
find-func derived eieio-load eieio-loaddefs cedet-load cedet-compat
cedet-loaddefs eieio warnings byte-opt bytecomp byte-compile cconv
macroexp inversion cl rainbow-delimiters evil evil-integration evil-maps
evil-commands evil-types evil-digraphs evil-search evil-ex evil-macros
evil-repeat evil-states evil-core advice help-fns advice-preload
evil-common windmove rect evil-vars ring edmacro kmacro goto-chg
undo-tree diff electric paren delsel autorevert time-date tooltip
ediff-hook vc-hooks lisp-float-type mwheel dos-w32 disp-table ls-lisp
w32-win w32-vars tool-bar dnd fontset image fringe lisp-mode register
page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs
button faces cus-face files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process multi-tty emacs)