Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Transformerlab App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
TransformerLab
Transformerlab App
Commits
b707b40b
Commit
b707b40b
authored
3 months ago
by
ali.asaria
Browse files
Options
Downloads
Patches
Plain Diff
check that ubuntu and wsl2 are default
parent
6a1af063
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/util.ts
+41
-0
41 additions, 0 deletions
src/main/util.ts
with
41 additions
and
0 deletions
src/main/util.ts
+
41
−
0
View file @
b707b40b
...
@@ -24,6 +24,8 @@ export function isPlatformWindows() {
...
@@ -24,6 +24,8 @@ export function isPlatformWindows() {
// On Windows, we use the home directory on WSL file system.
// On Windows, we use the home directory on WSL file system.
// This outputs how to access the WSL file system homedir from Windows.
// This outputs how to access the WSL file system homedir from Windows.
async
function
getWSLHomeDir
()
{
async
function
getWSLHomeDir
()
{
// We do not have to change the default encoding because this command
// is run on linux, not windows, so we get utf-8
const
{
stdout
,
stderr
}
=
await
awaitExec
(
'
wsl wslpath -w ~
'
);
const
{
stdout
,
stderr
}
=
await
awaitExec
(
'
wsl wslpath -w ~
'
);
if
(
stderr
)
console
.
error
(
`stderr:
${
stderr
}
`
);
if
(
stderr
)
console
.
error
(
`stderr:
${
stderr
}
`
);
const
homedir
=
stdout
.
trim
();
const
homedir
=
stdout
.
trim
();
...
@@ -73,6 +75,45 @@ export async function checkForMissingSystemRequirements() {
...
@@ -73,6 +75,45 @@ export async function checkForMissingSystemRequirements() {
return
'
TransformerLab API requires WSL to run on Windows.
'
;
return
'
TransformerLab API requires WSL to run on Windows.
'
;
}
}
try
{
// Let's call `wsl --status` and see what the default
// version and distro of wsl is:
// We must use encoding = utf16le because that is the default for powershell
// according to https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_character_encoding?view=powershell-7.4
// There is a potential for a bug here if the user changed their powershell encoding.
const
{
stdout
,
stderr
}
=
await
awaitExec
(
'
wsl --status
'
,
{
encoding
:
'
utf16le
'
});
if
(
stderr
)
return
stderr
;
//Read the output. The output looks like this:
//Default Distribution: Ubuntu
//Default Version: 2
//So parse out the distro and version:
const
lines
=
stdout
.
split
(
'
\n
'
);
let
distro
=
''
;
let
version
=
''
;
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
if
(
lines
[
i
].
includes
(
'
Default Distribution:
'
))
{
distro
=
lines
[
i
].
split
(
'
:
'
)[
1
];
}
if
(
lines
[
i
].
includes
(
'
Default Version:
'
))
{
version
=
lines
[
i
].
split
(
'
:
'
)[
1
];
}
}
distro
=
distro
.
trim
();
version
=
version
.
trim
();
// Now print out the distro and version:
console
.
log
(
`WSL distro:
${
distro
}
`
);
console
.
log
(
`WSL version:
${
version
}
`
);
// Check if the distro is set to Ubuntu and the version is 2
if
(
distro
!=
'
Ubuntu
'
||
version
!=
'
2
'
)
{
return
`WSL distro must be set to Ubuntu and version 2. Please run 'wsl --set-version Ubuntu 2'.`
;
}
}
catch
(
error
)
{
return
'
WSL is not enabled. Please enable WSL and install a distro.
'
;
}
try
{
try
{
// We will need to be able to use the wslpath utility
// We will need to be able to use the wslpath utility
// This may not be available if the user has not installed WSL
// This may not be available if the user has not installed WSL
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment