Re: Fail to install git from macports ("can't find file to patch" error)

2018-02-20 Thread Ryan Schmidt

On Feb 20, 2018, at 08:34, Joshua Kordani wrote:

> Not the OP, but regarding DYLD_LIBRARY_PATH, I don't understand how to make 
> use of dylib's provided by macports in my own programs without setting this 
> flag.  I've read in several places that, esp with macports, this should not 
> be necessary, but I don't know what the *right way* is.

What problem or error message are you encountering when you do not set 
DYLD_LIBRARY_PATH?



Re: Fail to install git from macports ("can't find file to patch" error)

2018-02-20 Thread Clemens Lang
Hi,

- On 20 Feb, 2018, at 15:34, Joshua Kordani jkord...@lsa2.com wrote:

> Not the OP, but regarding DYLD_LIBRARY_PATH, I don't understand how to
> make use of dylib's provided by macports in my own programs without
> setting this flag.  I've read in several places that, esp with macports,
> this should not be necessary, but I don't know what the *right way* is.

macOS is not Linux in this regard. macOS libraries are referenced from
binaries using their absolute path.

At a technical level, when you link a binary with, for example, -lcurl on
the command line, the linker will locate libcurl.dylib in the search paths
you've given on the command line (that should be -L/opt/local/lib for use
with MacPorts). It will then read the library id from the file. For our
example of MacPorts' libcurl, this is:

 $> otool -D /opt/local/lib/libcurl.dylib
 /opt/local/lib/libcurl.4.dylib

This path will then be copied into the linked binary. You can verify this
with the MacPorts curl binary:

 $> otool -L /opt/local/bin/curl | grep libcurl
 /opt/local/lib/libcurl.4.dylib (compatibility version 10.0.0, current version 
10.0.0)

When you run /opt/local/bin/curl, the loader reads this table and locates
this file using its absolute path. Setting DYLD_LIBRARY_PATH overrides this
and attempts to locate a file with the given basename in the directories
given in DYLD_LIBRARY_PATH, but if the library and the binary have been
built correctly (and not moved) you should never have to set it.

Of course this makes your binaries non-relocatable. If you want to relocate
binaries, you can use relative paths using the special variables @loader_path,
@executable_path and @rpath. See the dylibbundler port, which largely
automates this if you built your binaries with the -headerpad_max_install_names
linker flag (which MacPorts does by default).

-- 
Clemens Lang


Re: Fail to install git from macports ("can't find file to patch" error)

2018-02-20 Thread Ken Cunningham


> On Feb 20, 2018, at 06:34, Joshua Kordani  wrote:
> 
> Not the OP, but regarding DYLD_LIBRARY_PATH, I don't understand how to make 
> use of dylib's provided by macports in my own programs without setting this 
> flag.  I've read in several places that, esp with macports, this should not 
> be necessary, but I don't know what the *right way* is.

It seems very few people do know how, esp with xcode. 

This is why homebrew uses /usr/local and why it's so heavily recommended , to 
answer a question Ryan had in another thread. It is a default search path, and 
requires no configuration or insights to use it. Which is also it's downside...

Ken

> 
> 
>> On 2/19/18 5:18 PM, Ryan Schmidt wrote:
>>> On Feb 19, 2018, at 13:37, Qianqian Fang wrote:
>>> 
>>> I don't know what was changed recently, the built-in git command from Xcode 
>>> stopped working with the following error
>>> 
>>> fangq@jinwy:~/space/git/Project/autobuild/mcx$ git pull
>>> dyld: lazy symbol binding failed: Symbol not found: _iconv_open
>>>   Referenced from: 
>>> /Library/Developer/CommandLineTools/usr/libexec/git-core/git
>>>   Expected in: /opt/local/lib/libiconv.2.dylib
>>> 
>>> dyld: Symbol not found: _iconv_open
>>>   Referenced from: 
>>> /Library/Developer/CommandLineTools/usr/libexec/git-core/git
>>>   Expected in: /opt/local/lib/libiconv.2.dylib
>>> 
>>> error: fetch died of signal 6
>> Nothing of Apple's (such as 
>> /Library/Developer/CommandLineTools/usr/libexec/git-core/git) should be 
>> referencing anything of MacPorts's (such as 
>> /opt/local/lib/libiconv.2.dylib). The only reason that might happen is if 
>> you set DYLD_LIBRARY_PATH. So don't set that.
>> 
>>> I can only fix this if I put /usr/lib in the front of DYLD_LIBRARY_PATH, 
>>> but this breaks tons of other command.
>> You should not need to set DYLD_LIBRARY_PATH at all. Why do you think you 
>> need to?
>> 
>> 
>>> So, I decided to install a git from macports, however, this attempt failed 
>>> with the following error:
>>> 
>>> fangq@jinwy:~/space/git/Project/autobuild/mcx$ sudo port install git
>>> Warning: xcodebuild exists but failed to execute
>>> Warning: Xcode does not appear to be installed; most ports will likely fail 
>>> to build.
>>> --->  Computing dependencies for git
>>> --->  Applying patches to git
>>> Error: Failed to patch git: command execution failed
>>> Error: See 
>>> /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_devel_git/git/main.log
>>>  for details.
>>> Error: Follow https://guide.macports.org/#project.tickets to report a bug.
>>> Error: Processing of port git failed
>>> look at the main.log file, I found the error message attached at the end.
>>> 
>>> My macport version is 2.4.2, OS is Sierra, already ran port selfupdate.
>>> I have an old version of xcode (7.3) in order to compile cuda code, but I 
>>> don't think it was the issue.
>> I agree that an old Xcode would not cause a patch failure, but note that 
>> macOS Sierra requires Xcode 8 or 9.
>> 
>> 
>>> can someone let me know how to fix this? alternative approaches, such as 
>>> portable git binaries are also welcome, thanks a lot!
>>> Qianqian
>>> 
>>> 
>>> :debug:main Executing org.macports.main (git)
>>> :debug:main dropping privileges: euid changed to 502, egid changed to 505.
>>> :debug:main Skipping completed org.macports.archivefetch (git)
>>> :debug:main Privilege de-escalation not attempted as not running as root.
>>> :debug:main Skipping completed org.macports.fetch (git)
>>> :debug:main Privilege de-escalation not attempted as not running as root.
>>> :debug:main Skipping completed org.macports.checksum (git)
>>> :debug:main Privilege de-escalation not attempted as not running as root.
>>> :debug:main Skipping completed org.macports.extract (git)
>>> :debug:main Privilege de-escalation not attempted as not running as root.
>> The "Skipping" lines show us that this was not a clean attempt so no 
>> conclusions can be reached from it. "sudo port clean git" and try again.
>> 
>> 
> 


Re: Fail to install git from macports ("can't find file to patch" error)

2018-02-20 Thread Joshua Kordani
Not the OP, but regarding DYLD_LIBRARY_PATH, I don't understand how to 
make use of dylib's provided by macports in my own programs without 
setting this flag.  I've read in several places that, esp with macports, 
this should not be necessary, but I don't know what the *right way* is.



On 2/19/18 5:18 PM, Ryan Schmidt wrote:

On Feb 19, 2018, at 13:37, Qianqian Fang wrote:


I don't know what was changed recently, the built-in git command from Xcode 
stopped working with the following error

fangq@jinwy:~/space/git/Project/autobuild/mcx$ git pull
dyld: lazy symbol binding failed: Symbol not found: _iconv_open
   Referenced from: /Library/Developer/CommandLineTools/usr/libexec/git-core/git
   Expected in: /opt/local/lib/libiconv.2.dylib

dyld: Symbol not found: _iconv_open
   Referenced from: /Library/Developer/CommandLineTools/usr/libexec/git-core/git
   Expected in: /opt/local/lib/libiconv.2.dylib

error: fetch died of signal 6

Nothing of Apple's (such as 
/Library/Developer/CommandLineTools/usr/libexec/git-core/git) should be 
referencing anything of MacPorts's (such as /opt/local/lib/libiconv.2.dylib). 
The only reason that might happen is if you set DYLD_LIBRARY_PATH. So don't set 
that.


I can only fix this if I put /usr/lib in the front of DYLD_LIBRARY_PATH, but 
this breaks tons of other command.

You should not need to set DYLD_LIBRARY_PATH at all. Why do you think you need 
to?



So, I decided to install a git from macports, however, this attempt failed with 
the following error:

fangq@jinwy:~/space/git/Project/autobuild/mcx$ sudo port install git
Warning: xcodebuild exists but failed to execute
Warning: Xcode does not appear to be installed; most ports will likely fail to 
build.
--->  Computing dependencies for git
--->  Applying patches to git
Error: Failed to patch git: command execution failed
Error: See 
/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_devel_git/git/main.log
 for details.
Error: Follow https://guide.macports.org/#project.tickets to report a bug.
Error: Processing of port git failed
look at the main.log file, I found the error message attached at the end.

My macport version is 2.4.2, OS is Sierra, already ran port selfupdate.
I have an old version of xcode (7.3) in order to compile cuda code, but I don't 
think it was the issue.

I agree that an old Xcode would not cause a patch failure, but note that macOS 
Sierra requires Xcode 8 or 9.



can someone let me know how to fix this? alternative approaches, such as 
portable git binaries are also welcome, thanks a lot!
Qianqian


:debug:main Executing org.macports.main (git)
:debug:main dropping privileges: euid changed to 502, egid changed to 505.
:debug:main Skipping completed org.macports.archivefetch (git)
:debug:main Privilege de-escalation not attempted as not running as root.
:debug:main Skipping completed org.macports.fetch (git)
:debug:main Privilege de-escalation not attempted as not running as root.
:debug:main Skipping completed org.macports.checksum (git)
:debug:main Privilege de-escalation not attempted as not running as root.
:debug:main Skipping completed org.macports.extract (git)
:debug:main Privilege de-escalation not attempted as not running as root.

The "Skipping" lines show us that this was not a clean attempt so no conclusions can be 
reached from it. "sudo port clean git" and try again.






Re: Fail to install git from macports ("can't find file to patch" error)

2018-02-19 Thread Ryan Schmidt

On Feb 19, 2018, at 13:37, Qianqian Fang wrote:

> I don't know what was changed recently, the built-in git command from Xcode 
> stopped working with the following error
> 
> fangq@jinwy:~/space/git/Project/autobuild/mcx$ git pull
> dyld: lazy symbol binding failed: Symbol not found: _iconv_open
>   Referenced from: 
> /Library/Developer/CommandLineTools/usr/libexec/git-core/git
>   Expected in: /opt/local/lib/libiconv.2.dylib
> 
> dyld: Symbol not found: _iconv_open
>   Referenced from: 
> /Library/Developer/CommandLineTools/usr/libexec/git-core/git
>   Expected in: /opt/local/lib/libiconv.2.dylib
> 
> error: fetch died of signal 6

Nothing of Apple's (such as 
/Library/Developer/CommandLineTools/usr/libexec/git-core/git) should be 
referencing anything of MacPorts's (such as /opt/local/lib/libiconv.2.dylib). 
The only reason that might happen is if you set DYLD_LIBRARY_PATH. So don't set 
that.

> I can only fix this if I put /usr/lib in the front of DYLD_LIBRARY_PATH, but 
> this breaks tons of other command.

You should not need to set DYLD_LIBRARY_PATH at all. Why do you think you need 
to?


> So, I decided to install a git from macports, however, this attempt failed 
> with the following error:
> 
> fangq@jinwy:~/space/git/Project/autobuild/mcx$ sudo port install git
> Warning: xcodebuild exists but failed to execute
> Warning: Xcode does not appear to be installed; most ports will likely fail 
> to build.
> --->  Computing dependencies for git
> --->  Applying patches to git
> Error: Failed to patch git: command execution failed
> Error: See 
> /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_devel_git/git/main.log
>  for details.
> Error: Follow https://guide.macports.org/#project.tickets to report a bug.
> Error: Processing of port git failed
> look at the main.log file, I found the error message attached at the end.
> 
> My macport version is 2.4.2, OS is Sierra, already ran port selfupdate. 
> I have an old version of xcode (7.3) in order to compile cuda code, but I 
> don't think it was the issue.

I agree that an old Xcode would not cause a patch failure, but note that macOS 
Sierra requires Xcode 8 or 9.


> can someone let me know how to fix this? alternative approaches, such as 
> portable git binaries are also welcome, thanks a lot!
> Qianqian
> 
> 
> :debug:main Executing org.macports.main (git)
> :debug:main dropping privileges: euid changed to 502, egid changed to 505.
> :debug:main Skipping completed org.macports.archivefetch (git)
> :debug:main Privilege de-escalation not attempted as not running as root.
> :debug:main Skipping completed org.macports.fetch (git)
> :debug:main Privilege de-escalation not attempted as not running as root.
> :debug:main Skipping completed org.macports.checksum (git)
> :debug:main Privilege de-escalation not attempted as not running as root.
> :debug:main Skipping completed org.macports.extract (git)
> :debug:main Privilege de-escalation not attempted as not running as root.

The "Skipping" lines show us that this was not a clean attempt so no 
conclusions can be reached from it. "sudo port clean git" and try again.