public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Unexpected behavior of ~ when calling bash from a different cygwin installation
@ 2018-06-15 13:34 Soegtrop, Michael
  2018-06-15 14:49 ` Soegtrop, Michael
  0 siblings, 1 reply; 7+ messages in thread
From: Soegtrop, Michael @ 2018-06-15 13:34 UTC (permalink / raw)
  To: cygwin

Dear Cygwin users,

I have several Cygwin installation for different purposes (think of it as light weight VMs). I observe an unexpected behavior of ~ when I call a bash from one Cygwin from a bash of another Cygwin. The procedure is as follows:


*        I have a Cygwin in C:\bin\cygwinA

*        I start a bash via C:\bin\cygwinA\cygwin.bat

*        From this bash I start DOS batch file which first sets up a new Cygwin under C:\bin\cygwinB with a well-defined set of packages

*        The same batch file then starts a bash from CygwinB via C:\bin\cygwinB\bin\bash --login /cygdrive/c/bin/cygwinB/somefolder/somescript.sh

When I dump various paths from somescript.sh I get:


*        echo "$(cygpath -a -w /)"  =>  C:\bin\cygwinB

*        echo "$(cygpath -a -w .)"  => C:\bin\cygwinA\home\<user>

*        echo "$(cygpath -a -w ~)" => C:\bin\cygwinA\home\<user>

The first two are expected, but the last one is unexpected. I would have expected C:\bin\cygwinB\home\<user>. I don't understand why / is in cygwinB but ~ in cygwinA.

Best regards,

Michael
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Unexpected behavior of ~ when calling bash from a different cygwin installation
  2018-06-15 13:34 Unexpected behavior of ~ when calling bash from a different cygwin installation Soegtrop, Michael
@ 2018-06-15 14:49 ` Soegtrop, Michael
  2018-06-16  5:56   ` Andrey Repin
  2018-06-16 13:06   ` Marco Atzeri
  0 siblings, 2 replies; 7+ messages in thread
From: Soegtrop, Michael @ 2018-06-15 14:49 UTC (permalink / raw)
  To: cygwin

Dear Cygwin Users,

I got it, I just have to clear the HOME variable before.

But I have a few more observations on this:

the FAQ (section 4.20) state that the root path for the mount table depends on the path of the cygwin1.dll, to which an executable is linked. This doesn't seem to be the case. E.g. when I do

* start a bash via C:\bin\cygwinA\cygwin.bat 
* cd to /cygdrive/c/bin/cygwinB/bin
* ./bash

The first and the second bash have both /=C:\bin\cygwinA although SysInternals ProcExplorer clearly shows that the second bash loads the cygwin1.dll from C:\bin\cygwinB and not from C:\bin\cygwinA. Is there some description on how the path mapping really works?

If I do:

* start a bash via C:\bin\cygwinA\cygwin.bat 
* cd to /cygdrive/c/bin/cygwinB/bin
* /cygdrive/c/Windows/System32/cmd
* bash

The dlls to which the second bash links are the same in both cases, but in the second case /= C:\bin\cygwinB in the second shell.

And yes, I also read in section 4.20 of the FAQ that one shouldn't call one Cygwin from another. But I think a clear handover from one bash to another should work in a documented way.

Best regards,

Michael

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unexpected behavior of ~ when calling bash from a different cygwin installation
  2018-06-15 14:49 ` Soegtrop, Michael
@ 2018-06-16  5:56   ` Andrey Repin
  2018-06-16 11:13     ` Soegtrop, Michael
  2018-06-16 13:06   ` Marco Atzeri
  1 sibling, 1 reply; 7+ messages in thread
From: Andrey Repin @ 2018-06-16  5:56 UTC (permalink / raw)
  To: Soegtrop, Michael, cygwin

Greetings, Soegtrop, Michael!

> I got it, I just have to clear the HOME variable before.

> But I have a few more observations on this:

> the FAQ (section 4.20) state that the root path for the mount table depends
> on the path of the cygwin1.dll, to which an executable is linked.

"Linked" in this case should be read as "first cygwin1.dll loaded".

> This
> doesn't seem to be the case. E.g. when I do

> * start a bash via C:\bin\cygwinA\cygwin.bat 
> * cd to /cygdrive/c/bin/cygwinB/bin
> * ./bash

> The first and the second bash have both /=C:\bin\cygwinA although
> SysInternals ProcExplorer clearly shows that the second bash loads the
> cygwin1.dll from C:\bin\cygwinB and not from C:\bin\cygwinA. Is there some
> description on how the path mapping really works?

The mapping is consistent throughout the execution tree.

> If I do:

> * start a bash via C:\bin\cygwinA\cygwin.bat 
> * cd to /cygdrive/c/bin/cygwinB/bin
> * /cygdrive/c/Windows/System32/cmd
> * bash

> The dlls to which the second bash links are the same in both cases, but in
> the second case /= C:\bin\cygwinB in the second shell.

Indeed, since you cleanly broke out of cygwin execution tree.

> And yes, I also read in section 4.20 of the FAQ that one shouldn't call one
> Cygwin from another. But I think a clear handover from one bash to another should work in a documented way.

It does.
Do not mix Cygwin installations. At best, nothing will work, at worst, you'll
get unpredictable behavior that is hard to track down.
Each Cygwin installation have its own rebase map.


-- 
With best regards,
Andrey Repin
Saturday, June 16, 2018 2:34:34

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Unexpected behavior of ~ when calling bash from a different cygwin installation
  2018-06-16  5:56   ` Andrey Repin
@ 2018-06-16 11:13     ` Soegtrop, Michael
  0 siblings, 0 replies; 7+ messages in thread
From: Soegtrop, Michael @ 2018-06-16 11:13 UTC (permalink / raw)
  To: cygwin

Dear Andrey,

> The mapping is consistent throughout the execution tree.

I would like to understand the underlying mechanism. The documentation (FAQ section 4.20) states (as far as I understand) that the Windows path of the Cygwin system root an executable sees is the parent directory of the folder in which the cygwin1.dll resides which is loaded by an executable. As I showed, this doesn't seem to be the case. How does it work then? How is the system root folder passed from parent to child?

> At best, nothing will work

Actually if I put cmd in between and clear a few environment variables it works very well in fairly complicated scenarios. Still I would like to understand how the underlying mechanisms work (preferably without reverse engineering).

Best regards,

Michael
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unexpected behavior of ~ when calling bash from a different cygwin installation
  2018-06-15 14:49 ` Soegtrop, Michael
  2018-06-16  5:56   ` Andrey Repin
@ 2018-06-16 13:06   ` Marco Atzeri
  2018-06-16 18:27     ` Soegtrop, Michael
  1 sibling, 1 reply; 7+ messages in thread
From: Marco Atzeri @ 2018-06-16 13:06 UTC (permalink / raw)
  To: cygwin

On 6/15/2018 3:32 PM, Soegtrop, Michael wrote:
> Dear Cygwin Users,
> 
> I got it, I just have to clear the HOME variable before.
> 
> But I have a few more observations on this:
> 
> the FAQ (section 4.20) state that the root path for the mount table depends on the path of the cygwin1.dll, to which an executable is linked. This doesn't seem to be the case. E.g. when I do
> 
> * start a bash via C:\bin\cygwinA\cygwin.bat
> * cd to /cygdrive/c/bin/cygwinB/bin
> * ./bash
> 
> The first and the second bash have both /=C:\bin\cygwinA although SysInternals ProcExplorer clearly shows that the second bash loads the cygwin1.dll from C:\bin\cygwinB and not from C:\bin\cygwinA. Is there some description on how the path mapping really works?
> 

this is due to the preference given by Windows to load dll's from the
same directory where the program is resident instead of using the
ones in the PATH

I have the same issue when testing a new version of
GraphicsMagick perl interface

The perl program located in /usr/bin will alway use the installed
GM dll's  in the same directory instead of the new one I am trying
to test.



Regards
Marco





--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Unexpected behavior of ~ when calling bash from a different cygwin installation
  2018-06-16 13:06   ` Marco Atzeri
@ 2018-06-16 18:27     ` Soegtrop, Michael
  2018-06-17  2:14       ` cyg Simple
  0 siblings, 1 reply; 7+ messages in thread
From: Soegtrop, Michael @ 2018-06-16 18:27 UTC (permalink / raw)
  To: Marco Atzeri, cygwin

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 910 bytes --]

Dear Marco,

> this is due to the preference given by Windows to load dll's from the same
> directory where the program is resident instead of using the ones in the PATH

yes, this is expected behavior. What is not expected is that the location of the system root in the Windows file system does not depend on the loaded cygwin1.dll.

Best regards,

Michael
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
\0ТÒÐÐ¥\a&ö&ÆVÒ\a&W\x06÷'G3¢\x02\x02\x02\x02\x02\x02\x06‡GG\x03¢òö7–wv–âæ6öÒ÷\a&ö&ÆV×2æ‡FÖÀФd\x15\x13¢\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x06‡GG\x03¢òö7–wv–âæ6öÒöf\x17\x12ðФFö7VÖVçF\x17F–öã¢\x02\x02\x02\x02\x02\x02\x02\x02\x06‡GG\x03¢òö7–wv–âæ6öÒöFö72æ‡FÖÀÐ¥Vç7V'67&–&R\x06–æfó¢\x02\x02\x02\x02\x02\x06‡GG\x03¢òö7–wv–âæ6öÒöÖÂò7Vç7V'67&–&R×6–×\x06ÆPРÐ

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Unexpected behavior of ~ when calling bash from a different cygwin installation
  2018-06-16 18:27     ` Soegtrop, Michael
@ 2018-06-17  2:14       ` cyg Simple
  0 siblings, 0 replies; 7+ messages in thread
From: cyg Simple @ 2018-06-17  2:14 UTC (permalink / raw)
  To: cygwin

On 6/16/2018 9:33 AM, Soegtrop, Michael wrote:
> Dear Marco,
> 
>> this is due to the preference given by Windows to load dll's from the same
>> directory where the program is resident instead of using the ones in the PATH
> 
> yes, this is expected behavior. What is not expected is that the location of the system root in the Windows file system does not depend on the loaded cygwin1.dll.
> 

Cygwin uses the parent of the path containing the cygwin1.dll as the
root path.  Having multiple Cygwin's on disk isn't an issue.  Starting
another session of a Cygwin using cygwin1.dll on a different path is.
It just doesn't work properly.  Your use of windows cmd to clear the
environment and start another session on a different path works because
the children then don't have a reference to the original parent.

-- 
cyg Simple

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-06-16 20:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-15 13:34 Unexpected behavior of ~ when calling bash from a different cygwin installation Soegtrop, Michael
2018-06-15 14:49 ` Soegtrop, Michael
2018-06-16  5:56   ` Andrey Repin
2018-06-16 11:13     ` Soegtrop, Michael
2018-06-16 13:06   ` Marco Atzeri
2018-06-16 18:27     ` Soegtrop, Michael
2018-06-17  2:14       ` cyg Simple

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).