-1

I am using haskell version 8.2.2 on a mac and currently have a problem to compile a file :

My terminal:

$ls 
try.hs 
$ ghc -o try try.hs
<no location info>: error: can't find file: try.hs

Terminal after ls -l :

total 0 
-rw-rw-r--@ 1 <>  <> 0 Mar 23 15:54 try.hs 

Terminal after ls -l@ :

total 0
-rw-rw-r--@ 1 <>  <>  0 Mar 23 15:54 try.hs 
com.apple.TextEncoding  15 
com.apple.metadata:_kMDItemUserTags 42 
com.apple.metadata:kMDLabel_z4p7jqbpj7dblx5lt33gtc742u  105 
hhwwww
  • 83
  • 1
  • 2
  • 12
  • 1
    What do you get if you just use `ghc try.hs`? ghc isn't gcc. It names the binary based on the input file by default. – Carl Mar 23 '18 at 14:37
  • unfortunately same error – hhwwww Mar 23 '18 at 14:39
  • Unfortunately NOT same error. For me, with ghc 8.0.2 on Ubuntu 17.10, using the -o flag like this works just fine. – dvaergiller Mar 23 '18 at 14:42
  • 2
    What are the permissions on `try.hs`? What is the contents of `try.hs`? What are the permissions on the current directory? – Daniel Wagner Mar 23 '18 at 14:52
  • Hm, tried with ghc 8.2.2 in Ubuntu 17.10 and that also works perfectly. Can you do "ls -l" (that is a lower case L) – dvaergiller Mar 23 '18 at 14:54
  • the file is empty, permissions are read and write – hhwwww Mar 23 '18 at 14:54
  • There are many circumstances where `ls` would *appear* to show the existence of a file named `try.hs` when the file was actually named something else. What happens if you try `cat try.hs`? Does it find the file? – K. A. Buhr Mar 23 '18 at 14:56
  • 1
    @hhwwww And the permissions on the current directory? Bonus points for pasting the output of `ls -ld . try.hs`, so that we don't have to guess exactly what your vague "permissions are read and write" means. – Daniel Wagner Mar 23 '18 at 14:57
  • @hhwwww After typing up two or three different replies, I can only conclude that I don't know what you mean. I can't think of any sensible interpretation of "filetype was a text-edit document and now it isn't" that would affect whether GHC considered that file to exist or not. Whether the file name includes ".hs" or not is a red herring; names are just names, and can be whatever the heck you like, so long as the program you're using on the file likes it as well as you do. – Daniel Wagner Mar 23 '18 at 15:10
  • @DanielWagner thanks for ur time, i found the issue with ur help so it wasn't wasted :) the filetype was a text-edit document. Now I created a new one ... – hhwwww Mar 23 '18 at 15:25

1 Answers1

2

I suspect you have symlink'd a non-existent file to try.hs. Here is a sample of how things look in my test directory where I can see the same error as you:

% ls try.hs
try.hs
% ghc try.hs
<no location info>: error: can't find file: try.hs
% ls -l
total 0
lrwxrwxrwx. 1 <redacted> <redacted> 5 Mar 23 10:57 try.hs -> wrong

As you can see by the l at the beginning of the permissions and the -> wrong after the file name, here try.hs is a symlink to wrong. But there is no file named wrong.

Daniel Wagner
  • 145,880
  • 9
  • 220
  • 380