Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create user in News #36

Closed
hjek opened this issue Mar 3, 2016 · 21 comments
Closed

Unable to create user in News #36

hjek opened this issue Mar 3, 2016 · 21 comments

Comments

@hjek
Copy link

hjek commented Mar 3, 2016

When creating any user in News, after pressing signup, the app navigates to http://localhost:8080/y and gives the following error in the arc REPL:

arc> rename-file-or-directory: cannot rename file or directory
  source path: /var/tmp/cooks.14569798801456979880387
  dest path: /home/pelle/anarki/www/cooks
  system error: Invalid cross-device link; errno=18
  context...:
   /home/pelle/anarki/ac.scm:1153:13: mvfile
    signup-handler
    respond
    handle-request-thread

Just tested: Creating user works fine in News on arc3.1 here, but fails in anarki with above error.

@akkartik
Copy link
Member

akkartik commented Mar 3, 2016 via email

@hjek
Copy link
Author

hjek commented Mar 3, 2016

Ubuntu Wily 64-bit. Racket v6.2.

@akkartik
Copy link
Member

akkartik commented Mar 3, 2016

I just tried it and got a different error at the same place on OS X:

Type: unknown type
#<path:/var/folders/y_/00rkkq753tgf_n4qmg5njs4c003hjl/T/shash.14569804421456980442880>
  context...:
    ar-coerce
    +
    shash
    shash
    set-pw
    set-pw
    create-acct
    signup-handler
    respond
    handle-request-thread
    handle-request-thread
user break
  context...:
    socket-accept
    accept-request-with-deadline
    recur
   zz

My first guess is to suspect 7ae9fbc. Can you try undoing it and see if the problem goes away? It fixes the error on OS X.

@akkartik
Copy link
Member

akkartik commented Mar 3, 2016

I can reproduce your error on Linux. My suggestion doesn't fix it. I think it might be because /tmp is usually on a separate partition on Linux..

@hjek
Copy link
Author

hjek commented Mar 3, 2016

Did git reset --hard 7ae9fbc but it didn't solve problem.

@hjek
Copy link
Author

hjek commented Mar 3, 2016

I only have one disk partition.

@hjek
Copy link
Author

hjek commented Mar 3, 2016

Went really far back in the history to a commit from 2009, and there it works fine, and tried from my first commit in 2015 where it doesn't work. It seems silly to just do binary search through the git history until the commit introducing the error is narrowed down. There should be some cool git feature for that.

@akkartik
Copy link
Member

akkartik commented Mar 3, 2016

git bisect? :)

As an experiment I tried running it from /tmp on my machine, and the error went away. Can you try that as well, after making that mktemp change I mentioned above? Very strange to have two distinct issues hit us in the same place.

I think 2009 probably didn't use the system's mktemp function. Maybe that's the problem.

@hjek
Copy link
Author

hjek commented Mar 3, 2016

Tried running News from /tmp, and on creating a user, this error shows:

/tmp/anarki$ ./run-news 
rm: cannot remove ‘www/news/story/*.tmp’: No such file or directory
load items: 
ranking stories.
ready to serve port 8080

To quit:
  arc> (quit)
  (or press ctrl and 'd' at once)
For help on say 'string':
  arc> (help string)
For a list of differences with arc 3.1:
  arc> (incompatibilities)
To run all automatic tests:
  $ hg clone https://bitbucket.org/zck/unit-test.arc
  $ ./arc
  arc> (load "tests.arc")

If you have questions or get stuck, come to http://arclanguage.com/forum.
Arc 3.1 documentation: https://arclanguage.github.io/ref.
arc> Type: unknown type #<path:/var/tmp/shash.14569827321456982732871>
  context...:
   /tmp/anarki/ac.scm:1002:0: ar-coerce
   /tmp/anarki/ac.scm:752:8: +
    shash
    shash
    set-pw

@akkartik
Copy link
Member

akkartik commented Mar 3, 2016

Yes, that is fixed by undoing 7ae9fbc

@hjek
Copy link
Author

hjek commented Mar 3, 2016

Even after that particular commit is undone, the error is still happening. Might do git bisect - it looks nice.

@akkartik
Copy link
Member

akkartik commented Mar 3, 2016 via email

@hjek
Copy link
Author

hjek commented Mar 3, 2016

@akkartik , the fix you made for #37 partly fixes this: I can create user in News when it is run from /tmp/. I think the remaining issue has to do with some way Ubuntu handles /tmp/, but I assume I can fix it by changing "/tmp/" to some other folder in ac.scm:

(define (ar-tmpname)
  (call-with-input-file "/dev/urandom"
    (lambda (rstr)
      (do ((s "/tmp/")
           (c (read-char rstr) (read-char rstr))
           (i 0 (+ i 1)))
          ((>= i 16) s)
        (set! s (string-append s
                               (string
                                 (integer->char
                                   (+ (char->integer #\a)
                                      (modulo
                                        (char->integer (read-char rstr))
                                        26))))))))))

While I don't need this to run on Windows, /tmp/ and /dev/urandom are definitely not gonna work there. And I wonder if it would make sense to:

  • change temporary file location from /tmp to tmp (because of Ubuntu and Windows)
  • instead of /dev/urandom, use arc's (rand) for the names of the temporary files (because of Windows)

@hjek
Copy link
Author

hjek commented Mar 3, 2016

Oh, ac.scm is a mzcheme file, so it'll be (random) instead of (rand).

@akkartik
Copy link
Member

akkartik commented Mar 3, 2016

I actually thought we'd gotten rid of ar-tmpname.. The advantage of mktemp is like you pointed out that it's cross-platform and doesn't rely on /dev/urandom and so on. The other advantage of mktemp is that since it's for temporary filenames in particular, it has better multi-threaded properties. It returns the filename only after creating it with an atomic operation, so if you have lots of threads opening temporary files at once you're guaranteed to never get a collision.

It turns out that mktemp takes a directory argument, so maybe it's just a matter of changing it to tmp or something else?

@akkartik
Copy link
Member

akkartik commented Mar 3, 2016

That seems to work. Submitting now; let me know if that fixes things for you.

@hjek
Copy link
Author

hjek commented Mar 3, 2016

Changing tmpdir* to tmp in arc.arc does solve the signup and login problem on Ubuntu.

@hjek
Copy link
Author

hjek commented Mar 3, 2016

I'll try your fix before submitting anything. Otherwise moving the temporary folder from "default location" to anarki/tmp does the trick. But I think it's a good idea to do (ensure-dir "tmp") in that case.

@akkartik
Copy link
Member

akkartik commented Mar 3, 2016

Yeah I noticed that as well :) Actually if you have a commit already in place you can go ahead and submit. We'll see how I did :)

@hjek
Copy link
Author

hjek commented Mar 3, 2016

Still had the same error after your commit. I'll push my fix.

@hjek hjek closed this as completed in 70b7994 Mar 3, 2016
@akkartik
Copy link
Member

akkartik commented Mar 3, 2016 via email

akkartik added a commit that referenced this issue Mar 3, 2016
Slight change to #36. This way any change to the tmp directory will
continue to work. Hopefully the additional overhead isn't serious..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants