I can imagine defining file paths something like this:
(define file1
(string-append
(path->string (expand-user-path))
()
"file1"))
What is recommended for ?
My current racket installation has:
(string-append
(path->string (expand-user-path))
".plt-scheme/4.2.1/collects/DG/"
"<...>"
"file1"))
To make use of should I:
a) move my dirs of modules here: ?
OR
b) re-install Racket & place my dirs of modules here: ?
Simple examples, see the docs for caveats, exceptions, and additional features:
(require "main.rkt") ; load the file 'main.rkt' which is in the same directory as the current file
(require "../utils/hash.rkt") ; load the file 'hash.rkt' which is up one level then down into the 'utils' directory
(require struct-plus-plus) ; Load the 'struct-plus-plus' module. Racket will figure out where it is
How do I refer to a file from a known location relative to the current file when that file is not a module?
; Assume that current directory is /Users/dstorrs/code
#lang racket
(require racket/runtime-path)
(define here ".")
(define-runtime-path this-dir ".")
(define without-runtime-path (build-path here 'up "projects" "main.rkt"))
(define with-runtime-path (build-path this-dir 'up "projects" "main.rkt"))
(displayln (~a "Using define, you get: " (~v without-runtime-path)))
(displayln (~a "Using define-runtime-path, you get: " (~v with-runtime-path)))
(path->string with-runtime-path)
(build-path this-dir "../foo/bar/") ; you can build paths in one chunk too
Output:
Using define, you get: #<path:./../projects/main.rkt>
Using define-runtime-path, you get: #<path:/Users/dstorrs/code/./../projects/main.rkt>
"/Users/dstorrs/code/./../projects/main.rkt"
#<path:/Users/dstorrs/code/./../foo/bar/>
Maybe I just need to create a package with the path: ".plt-scheme/4.2.1/collects/DG/"
Then the path definition would be like this:
(define file1 (string-append (path->string (expand-user-path)) "file1"))
No wonder there is difficulty in understanding what I have written since Discourse is removing chunks of it.
Here is another try:
Maybe I just need to create a package with the path: ".plt-scheme/4.2.1/collects/DG/"
Then the path definition would be something like this:
(define file1 (string-append (path->string (expand-user-path)) pkg "file1"))
I assume that if I create a package then there is some function, maybe just the name of the package, that will return the path of the package. That is all that I am after.
Thanks
It sounds like you want to refer to files that are in a known location with respect to the source code. So, for instance, I might have a file called "email-processor.rkt" with a file called "email-rules.csv" that's in the same directory. In this case, I would echo Ryan Culpepper's suggestion that you use the runtime-path functions. here's a snippet of code that illustrates what I mean:
#lang racket
(require racket/runtime-path)
(define-runtime-path here ".")
(file->string (build-path here "email-rules.csv"))
Again, it would help if you would tell us what you are trying to achieve. What is the purpose of this code? Are you loading configuration data, calling out to a shell script, or what?
Currently, my system returns these:
(require setup/dirs)
(find-user-collects-dir) ;=> #path:/home/don/.racket/8.1/collects
; but I want it to return: #.plt-scheme/4.2.1/collects>
(find-collects-dir) ;=> #path:/home/don/racket/collects/
; but I want it to return: #.plt-scheme/4.2.1/collects>
(define-runtime-path here ".")
(file->string (build-path here "email-rules.csv"))
instead of using:
(define-runtime-path here "/home/don/.plt-scheme/4.2.1/collects/DG/all/")
(file->string (build-path here "email-rules.csv"))
However, before I start using collection-file-path, I want to be confident in my ability to manage the collects paths so that I only have one available.
Since my system currently has collect paths that I am not using, I'd like to remove them.
Am I correct in thinking that the only way to remove them is to uninstall Racket installations that I am not using?
I am using racket 8.1 so the question arises:
How do I configure racket 8.1 to use a collects path that is not the default:
#path:/home/don/.racket/8.1/collects
Wow. I have PLT Scheme v4.2.1 on my machine but it's from 2009, which I suppose is the first time I tried to pick a Lisp. You've been doing this a while, eh?
It sounds like you want to do two things:
Specify where you want collections to load from
Eliminate all loading options aside from the one you specify