# rake를 통한 테마 컴포넌트 업그레이드가 작동하지 않습니다

**URL:** https://meta.discourse.org/t/theme-component-upgrade-via-rake-not-working/152322
**Category:** Support
**Created:** [5월 22, 2020, 12:14오후 UTC](https://meta.discourse.org/t/theme-component-upgrade-via-rake-not-working/152322 "2020-05-22T12:14:53Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![chandan.gupta](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chandan.gupta/32/180765_2.png) [@chandan.gupta](https://meta.discourse.org/u/chandan.gupta)
#### Post date: [5월 22, 2020, 12:14오후 UTC](https://meta.discourse.org/t/theme-component-upgrade-via-rake-not-working/152322/1 "2020-05-22T12:14:53Z")

</div>

우리는 `rake` 명령을 통해 설치하는 테마 컴포넌트를 가지고 있습니다. 해당 플러그인과 `rake` 명령을 통한 설치 과정은 완벽하게 정상 작동합니다. 관리자 UI, 예를 들어 `/admin/customize/themes/40`에서 업그레이드를 수행할 때도 완벽하게 정상 작동합니다. 문제는 해당 `rake` 명령을 통해 커맨드 라인에서 업그레이드를 시도할 때 발생합니다. 출력 결과는 제가 예상한 것과 정확히 일치합니다. 그러나 변경 사항이 반영되지 않습니다. 이는 버그로 보이나요?

```
$ rake themes:install -- '--{"discourse-login-modal": {"url": "https://github.com/example/discourse-login-modal.git", "add_to_all_themes": true}}'
discourse-login-modal: 이미 설치되어 있습니다. 원격에서 업데이트 중입니다.

결과:
 설치됨: 0
 업데이트됨: 1
 오류: 0

```

---

<div class="post-metadata">

### Author: ![chandan.gupta](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chandan.gupta/32/180765_2.png) [@chandan.gupta](https://meta.discourse.org/u/chandan.gupta)
#### Post date: [5월 22, 2020, 12:41오후 UTC](https://meta.discourse.org/t/theme-component-upgrade-via-rake-not-working/152322/2 "2020-05-22T12:41:35Z")

</div>

문제의 세부 사항을 추가로 설명합니다. 업그레이드를 위한 rake 명령을 실행해도 테마 컴포넌트에 눈에 띄는 변화가 없지만, 그 후 Admin UI는 업그레이드가 적용된 것으로 인식합니다(스크린샷을 캡처하지 못했습니다).

이후 테마 컴포넌트에 변경 사항을 가하면 Admin UI에 업그레이드가 사용 가능하다고 표시되지만, 이를 적용하면 로컬 변경 사항이 덮어쓰기된다는 경고가 표시됩니다. 이 변경 사항들은 실제로 적용되지 않은 rake install 명령을 통해 적용하고자 했던 내용과 정확히 일치합니다.

 ![Screenshot 2020-05-22 at 6.01.36 PM](https://global.discourse-cdn.com/meta/original/3X/0/4/042c58a8f8f66043158acb573fd882521c70dd06.png)  
 ![Screenshot 2020-05-22 at 6.00.22 PM](https://global.discourse-cdn.com/meta/original/3X/1/e/1ee365f23e5110af48af8541d7f3896d7fdc3cc3.png) .

---

<div class="post-metadata">

### Author: ![chandan.gupta](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chandan.gupta/32/180765_2.png) [@chandan.gupta](https://meta.discourse.org/u/chandan.gupta)
#### Post date: [5월 22, 2020, 6:14오후 UTC](https://meta.discourse.org/t/theme-component-upgrade-via-rake-not-working/152322/3 "2020-05-22T18:14:42Z")

</div>

@markvanlan 님, 안녕하세요! 테마를 설치하기 위한 rake 명령어 작업에 감사드립니다. rake install을 통한 업그레이드가 작동하지 않는 이유가 무엇인지 아시나요?

---

<div class="post-metadata">

### Author: ![markvanlan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markvanlan/32/160087_2.png) [@markvanlan](https://meta.discourse.org/u/markvanlan)
#### Post date: [5월 25, 2020, 1:42오후 UTC](https://meta.discourse.org/t/theme-component-upgrade-via-rake-not-working/152322/4 "2020-05-25T13:42:54Z")

</div>

이번 주 안에 조금 더 살펴볼게요. rake 명령어가 작동하지 않는다는 사실은 몰랐어요.

---

<div class="post-metadata">

### Author: ![chandan.gupta](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chandan.gupta/32/180765_2.png) [@chandan.gupta](https://meta.discourse.org/u/chandan.gupta)
#### Post date: [6월 28, 2020, 10:36오전 UTC](https://meta.discourse.org/t/theme-component-upgrade-via-rake-not-working/152322/5 "2020-06-28T10:36:13Z")

</div>

업데이트가 작동하지 않는 이유를 파악하지 못했지만, 임시 해결책으로 언인스톨 명령어를 추가하는 방법을 떠올렸습니다. rake install 명령어를 사용하기 전에 테마를 언인스톨하면 작동하는 것 같습니다.

이 접근 방식이 괜찮은지 확인하기 위해 짧은 PR을 올렸습니다: [[WIP] FEATURE: Rake task to uninstall theme - Pull Request #10138 - discourse/discourse - GitHub](https://github.com/discourse/discourse/pull/10138)

---

<div class="post-metadata">

### Author: ![markvanlan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markvanlan/32/160087_2.png) [@markvanlan](https://meta.discourse.org/u/markvanlan)
#### Post date: [6월 29, 2020, 2:09오후 UTC](https://meta.discourse.org/t/theme-component-upgrade-via-rake-not-working/152322/6 "2020-06-29T14:09:45Z")

</div>

이 문제에 대해 후속 조치를 하지 못한 점 죄송합니다!

이 문제가 업데이트되지 않는 이유에 대해 짐작이 갑니다. 제 추측이 맞다면, 매우 빠르게 수정할 수 있을 것입니다.

---

<div class="post-metadata">

### Author: ![markvanlan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markvanlan/32/160087_2.png) [@markvanlan](https://meta.discourse.org/u/markvanlan)
#### Post date: [6월 29, 2020, 3:08오후 UTC](https://meta.discourse.org/t/theme-component-upgrade-via-rake-not-working/152322/7 "2020-06-29T15:08:02Z")

</div>

여기 뭔가 아주 이상합니다. `ThemesInstallTask`가 원격 테마를 업데이트할 때, 원격 정보는 올바르게 업데이트됩니다(최신 sha가 표시되고, 언급하신 대로 commits\_behind가 0입니다).

 ![Screenshot from 2020-06-29 10-02-25](https://global.discourse-cdn.com/meta/original/3X/1/0/10b49ea1f26cb0eea0b429d1f80a1f2260e6fa4b.png)

하지만 데이터베이스의 scss는 업데이트되지 않습니다. 캐시 버스팅(cache busting) 문제인 줄 알았는데, 그렇지 않다는 것을 확인했습니다! 데이터베이스의 scss가 실제로 업데이트되지 않고 있습니다.

 ![Screenshot from 2020-06-29 10-03-21](https://global.discourse-cdn.com/meta/original/3X/4/e/4e6b2c13d444c513b0b7d1cfa7ba4ca57286374a.png)  
이 스크린샷에서는 값이 달라야 합니다

관리자 테마 컨트롤러가 업데이트를 처리하는 방식과 태스크가 원격 테마를 업데이트하는 방식을 비교해 보았지만, 차이점을 찾지 못했습니다.

🕵️‍♂️ 🔍

이 수수께끼를 끝까지 파헤쳐 보겠습니다.

---

<div class="post-metadata">

### Author: ![markvanlan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markvanlan/32/160087_2.png) [@markvanlan](https://meta.discourse.org/u/markvanlan)
#### Post date: [6월 29, 2020, 3:37오후 UTC](https://meta.discourse.org/t/theme-component-upgrade-via-rake-not-working/152322/8 "2020-06-29T15:37:26Z")

</div>

문제의 원인을 파악했고 PR을 만들었습니다. 설명란에 해당 문제를 자세히 설명해 두었습니다.

> <https://github.com/discourse/discourse/pull/10143>
>
> Theme values were not actually being updated via the theme install rake task, be…cause \`update\_from\_remote\` does not save the theme.
> 
> In the admin controller, when updating a theme from remote, we see
> 
> https://github.com/discourse/discourse/blob/fe284ffd06f759a7109601609d71357599c04c0a/app/controllers/admin/themes\_controller.rb#L207
> 
> And then \`theme\` is saved later in the action
> https://github.com/discourse/discourse/blob/fe284ffd06f759a7109601609d71357599c04c0a/app/controllers/admin/themes\_controller.rb#L211
> 
> The update\_from\_remote method sets fields on the \`theme\`, but does not save the theme.
> https://github.com/discourse/discourse/blob/fe284ffd06f759a7109601609d71357599c04c0a/app/models/remote\_theme.rb#L176
> 
> In the rake task, I was assuming that the theme was automatically saved by \`update\_from\_remote\`, so adding save here is a fix! It is a bit of an interesting paradigm to wait to save \`theme\` outside the update method, but it makes more sense in the context of how the controller uses the method.

병합 완료! 업데이트가 수정되었습니다.

---

<div class="post-metadata">

### Author: ![markvanlan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markvanlan/32/160087_2.png) [@markvanlan](https://meta.discourse.org/u/markvanlan)
#### Post date: [6월 29, 2020, 7:58오후 UTC](https://meta.discourse.org/t/theme-component-upgrade-via-rake-not-working/152322/9 "2020-06-29T19:58:27Z")

</div>


