]> Untitled Git - lemmy.git/blob - docs/src/contributing_local_development.md
Change domain of yerbamate.dev to yerbamate.ml
[lemmy.git] / docs / src / contributing_local_development.md
1 ### Install build requirements
2 #### Ubuntu
3 ```
4 sudo apt install git cargo libssl-dev pkg-config libpq-dev yarn curl gnupg2 espeak
5 # install yarn
6 curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
7 echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
8 sudo apt update && sudo apt install yarn
9 ```
10
11 #### macOS
12
13 Install Rust using [the recommended option on rust-lang.org](https://www.rust-lang.org/tools/install) (rustup).
14
15 Then, install [Homebrew](https://brew.sh/) if you don't already have it installed.
16
17 Finally, install Node and Yarn.
18
19 ```
20 brew install node yarn
21 ```
22
23 ### Get the back end source code
24 ```
25 git clone https://github.com/LemmyNet/lemmy.git
26 # or alternatively from gitea
27 # git clone https://yerbamate.ml/LemmyNet/lemmy.git
28 ```
29
30 ### Build the backend (Rust)
31 ```
32 cargo build
33 # for development, use `cargo check` instead)
34 ```
35
36 ### Get the front end source code
37 ```
38 git clone https://github.com/LemmyNet/lemmy-ui.git
39 # get the translations
40 git submodule init
41 git submodule update --remote
42 ```
43
44 ### Setup postgresql
45 #### Ubuntu
46 ```
47 sudo apt install postgresql
48 sudo systemctl start postgresql
49
50 # Either execute db-init.sh, or manually initialize the postgres database:
51 sudo -u postgres psql -c "create user lemmy with password 'password' superuser;" -U postgres
52 sudo -u postgres psql -c 'create database lemmy with owner lemmy;' -U postgres
53 export LEMMY_DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy
54 ```
55
56 #### macOS
57 ```
58 brew install postgresql
59 brew services start postgresql
60 /usr/local/opt/postgres/bin/createuser -s postgres
61
62 # Either execute db-init.sh, or manually initialize the postgres database:
63 psql -c "create user lemmy with password 'password' superuser;" -U postgres
64 psql -c 'create database lemmy with owner lemmy;' -U postgres
65 export LEMMY_DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy
66 ```
67
68 ### Run a local development instance
69 ```
70 cd lemmy
71 cargo run
72 ```
73
74 Then open [localhost:1235](http://localhost:1235) in your browser. To reload back-end changes, you will have to rerun `cargo run`. You can use `cargo check` as a faster way to find compilation errors.
75
76 To do front end development:
77
78 ```
79 cd lemmy-ui
80 yarn
81 yarn dev
82 ```
83
84 and go to [localhost:1234](http://localhost:1234). Front end saves should rebuild the project.
85
86 Note that this setup doesn't include image uploads or link previews (provided by pict-rs and
87 iframely respectively). If you want to test those, you should use the
88 [Docker development](contributing_docker_development.md).