AI refac
Reference

بِسْمِ ٱللَّهِ ٱلرَّحْمَـٰنِ ٱلرَّحِيمِ

Environment Variables

Every environment variable refac reads, where it looks for language servers, and what it keeps on your machine.

Set these once in your shell profile and the commands will inshallah stay short.

Variables

VariableMeaningDefault
REFAC_PROJECT_PATHThe default for --project-pathThe current directory
REFAC_GOPLSWhere gopls is installedPATH, $GOBIN, $GOPATH/bin, ~/go/bin
REFAC_RUST_ANALYZERWhere rust-analyzer is installedPATH, then ~/.cargo/bin. rustup picks the toolchain from --project-path
REFAC_PYTHON_SERVERThe basedpyright-langserver for Python renamePATH, ~/.local/bin, and the project's .venv/bin and venv/bin
REFAC_DARTThe dart binaryPATH, $FLUTTER_ROOT/bin/cache/dart-sdk/bin
REFAC_KOTLIN_SERVERThe folder of the Kotlin language server, the one with bin/intellij-serverNone. refac never downloads it
REFAC_LSP_TIMEOUT_SECSHow long a server may take to load or answer300
REFAC_KOTLIN_TIMEOUT_SECSThe same for the Kotlin Gradle import600
REFAC_KOTLIN_CACHEWhere the Kotlin server keeps its index between calls: a directory, or off~/.cache/refac
REFAC_KOTLIN_MIRROR_VERSIONThe Kotlin version of the plain-JVM copy used for a Multiplatform build, when the project does not state one in a place refac readsRead from the project
REFAC_KOTLIN_BATCH_ONLY0 lets a single Kotlin move or rename through. 1, empty, or unset refuses it. Anything else is an errorRefuse
REFAC_KOTLIN_GRADLE_IDLE_SECSKeep the Kotlin project's Gradle daemon up that many seconds after a command, from 1 to 3600Off. The daemon stops 10 s after the import
REFAC_TYPESCRIPT_MAX_RSS_MBThe RAM limit of the TypeScript helper, in MiB4096
REFAC_DRY_RUN_COPY_MAX_MBThe size limit of the throw-away copy that dry runs of Python (Rope), Kotlin, and move-module --check use500
REFAC_LSP_TRACE1 prints every message exchanged with a serverOff
RUST_LOGdebug shows more of refac's own log on stderrOff

A server that does not answer is an error after the timeout, and never a hang.

How a server is found

  1. The environment variable of the language. If it is set, it is the only place looked at, so a wrong value is reported as wrong instead of silently replaced.
  2. Otherwise the PATH.
  3. Otherwise the folders that installers use, which are the language's own toolchain folders.

A place counts only when the program there runs. A stand-in that exists but fails, such as rustup's rust-analyzer without the component, is reported as broken.

When a server is missing, the failing command lists every place it looked and stops. Then run refac doctor <language> for the install steps and a start check, install the tool, and run the original command again.

What refac keeps on your machine

Only the Kotlin server's index: 110 to 160 MB in ~/.cache/refac, deleted when it passes 2 GB. It is why the next Kotlin call is ready in 9 to 16 seconds instead of 32 to 38. REFAC_KOTLIN_CACHE=off keeps nothing, and a directory moves it.

The Kotlin Gradle daemon is told to stop itself 10 seconds after the import, instead of the three hours that Gradle defaults to. REFAC_KOTLIN_GRADLE_IDLE_SECS keeps it longer when you ask. Nothing else stays: every other server stops when its command ends.

On this page