HaxeFoundation / haxelib

The Haxe library manager
https://lib.haxe.org/
MIT License
173 stars 78 forks source link

Problem with PWD in OS X #196

Closed boozook closed 8 years ago

boozook commented 9 years ago

See log:

$ haxelib config
/Users/ak/Developer/Haxe/libs/
fzzr:h3d ak$ PWD
/Users/ak/Developer/Haxe/libs/h3d
fzzr:h3d ak$ haxelib remove h3d
Library h3d removed
fzzr:h3d ak$ PWD
PWD: .: No such file or directory
fzzr:h3d ak$ haxelib list
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
/usr/lib/haxe/std/neko/_std/Sys.hx:87: characters 2-24 : Error chdir list
tools/haxelib/Main.hx:309: characters 17-43 : Called from
tools/haxelib/Main.hx:1508: characters 2-22 : Called from
--macro:1: character 0 : Called from
Aborted

fzzr:h3d ak$ haxelib version
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
/usr/lib/haxe/std/neko/_std/Sys.hx:87: characters 2-24 : Error chdir version
tools/haxelib/Main.hx:309: characters 17-43 : Called from
tools/haxelib/Main.hx:1508: characters 2-22 : Called from
--macro:1: character 0 : Called from
Aborted

fzzr:h3d ak$ cd ..
fzzr:libs ak$ haxelib version
3.2.0-rc.3

Are really needed getcwd for any haxelib's command like list or info or version? It need only for local or dev.

boozook commented 9 years ago

I don't know how and when :), but I partially fixed this issue in the https://github.com/HaxeFoundation/haxelib/pull/197 . Tests will be soon.

Log:

$ haxelib version
3.2.0-rc.3
$ mkdir temp; cd temp; rm -r ../temp; haxelib list; cd ..
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
/usr/lib/haxe/std/neko/_std/Sys.hx:87: characters 2-24 : Error chdir list
tools/haxelib/Main.hx:309: characters 17-43 : Called from
tools/haxelib/Main.hx:1508: characters 2-22 : Called from
--macro:1: character 0 : Called from
Aborted

And my. I change version to "3.2.0-rc.4" only for me.

$ neko haxelib.n version
3.2.0-rc.4
$ mkdir temp; cd temp; rm -r ../temp; neko ./../haxelib.n list; cd ..
actuate: 1.6.2 1.6.4 1.6.5 1.6.7 1.6.8 1.7.0 1.7.1 1.7.2 1.7.3 1.7.5 1.8.0 1.8.1 1.8.2 [1.8.3]
aether: 1.7.0 [1.7.1]
air3: [0.0.1]
...
xspf: [1.1.0]
yagp: [1.1.4]
ze2d: 0.2.0 0.2.1 [0.3.3]

But not fully. I'll fix it soon.

$ mkdir temp; cd temp; rm -r ../temp; neko ./../haxelib.n upgrade; cd ..
Checking actuate
Checking aether
Checking air3
Checking arrowlets
Checking as3tohx
No such Project : as3tohx
Checking asparticles
std@get_cwd

std@get_cwd - that is it.

boozook commented 9 years ago
  1. I partially fixed this issue in the #197;
  2. Need tests for OS X and other OSs.
nadako commented 8 years ago

I feel like haxelib shouldn't contain such a hack for this specific situation. Couldn't we just check for whether cwd is valid at start and error if not?

boozook commented 8 years ago

Agree only if we won't use CWD where it is not needed. Currently (if I remember correctly) CWD used in all methods.

Are really needed getcwd for any haxelib's command like list or info or version? It need only for local or dev.


I agree that this is ugly solution and it works not absolutely correctly.

Couldn't we just check for whether cwd is valid at start and error if not?

  1. CWD should be used only where it is really needed.
  2. Otherwise (e.g. for local & dev) - check for whether cwd is valid.

P.s.: Actually this is not a very rare situation and is easily reproduced.This should not be neglected. P.p.s: This week I sit down at the refactoring Haxelib-tool. If you have any advise or your endeavor is not in the main branch - please point me.

nadako commented 8 years ago

Okay, I'll try reproducing that on OS X by removing the fix locally and see what can we do about not querying cwd when not needed.

As for the refactoring, I'm currently trying to modularize stuff and I started with factoring out the installation repository management stuff (install/remove/query libraries). It's still unfinished, but I'm doing it in the repository branch. What I am trying to achieve with that is a simple class that one can instantiate passing a repository root to its constructor and then manage installed libs using its methods. It has no knowledge of networking affairs or any global configuration and whatnot.

boozook commented 8 years ago

:ok_hand: :+1: I love blackbox conception and encapsulation. I will write a letter to you personally. @nadako

nadako commented 8 years ago

I tested it on linux and it seems that cwd is not required for all commands nowadays. So I'm going to simply add handling of std@get_cwd and std@set_cwd errors in the global catch for proper error message, and remove the PWD hack.

boozook commented 8 years ago

So much better! I will tested it on OS X in my use-cases.